This is my WSL configuration for my arch WSL instance.
I have not tested these dotfiles on other WSL distributions and am not sure how will they work.
You also need to do simple little tweaks here and there to get things working, there are too many to list but they are simple enough that a simple google search should help you.
This is a very basic configuration for WSL2 on Windows 11 using yuk7’s ArchWSL.
This configuration also heavily relies on Aitor Alono’s article on how to use GUI apps in WSL2.
This configuration uses WezTerm on the Windows side to spawn directly into the WSL instance without going through powershell though any terminal can work.
- lf
- fzf
- ueberzug++
- trash-cli
- bat
- ffmpegthumbnailer
- imagemagick
- poppler
- epub-thumbnailer
- wkhtmltopdf
- chafa
pgtk
and native-comp
but due to some hibernation issues I faced with WSLg, I switched over to forwarding a X server with VcXsrv. So you don’t need to compile emacs from scratch anymore, but it is still the prefered method to install emacs as compared to a distro repository.
# Install the necessary developement tools sudo pacman -S base-devel git --needed sudo pacman -S libxpm libjpeg libpng libtiff giflib librsvg libxml2 gnutls gtk3 webkit2gtk --needed # Clone the Emacs repository git clone git://git.sv.gnu.org/emacs.git # cd into the Emacs repository cd emacs # Generate build files ./autogen # Configure the Emacs features per your needs ./configure --with-native-compilation=aot --with-xwidgets --with-tree-sitter --with-json --with-imagemagick --with-mailutils # Build Emacs make # Install Emacs sudo make installTo setup WezTerm with
wezterm.lua
, after installing wezterm you need to move to move wezterm.lua
to where you have installed WezTerm, typically C:\Program Files\WezTerm
. Doing so might require administrator privilages.
After VcxSrv is installed, we need to ensure the proper rules for VcxSrv on our firewall. These steps assume you do not have custom firewall rules(like an antivirus). If you do have custom rules set, you may need to configure it manually.
To ensure the proper firewall rules, open Windows Security
,go to Firewall & network protection
-> Allow an app through firewall
and ensure VcXsrv windows xserver
has both Private networks
and Public networks
permissions.
Windows/config.xlaunch
file to the %AppData%\Microsoft\Windows\Start Menu\Programs\Startup
directory and enable it in TaskManager
If you experience blurry fonts, follow this answer.
To make a shortcut for any GUI application for VcXsrv, right-click on desktop, click New
-> Shortcut
and put the shortcut command as such C:\Windows\System32\wsl.exe --distribution Arch zsh -ic "/your command here/"
To enable systemd, you need to edit /etc/wsl.conf
with sudo privileges i.e. sudo vim /etc/wsl.conf
and add the following lines
[boot] systemd=true
and then restart your WSL instance by going into the windows terminal and typing the followin command wsl --shutdown
and then opening WezTerm.
vim ~/.config/systemd/user/emacs.service
[Unit] Description=Emacs text editor (daemon) [Service] Type=forking ExecStart=/usr/local/bin/emacs --daemon ExecStop=/usr/local/bin/emacsclient --eval "(progn (setq kill-emacs-hook 'nil) (kill-emacs))" Restart=always [Install] WantedBy=default.target
systemctl --user daemon-reload
systemctl --user enable emacs.service
If you see me doing anything inefficiently in this config or you think something would be useful to me or you want to correct some error on my part, feel free to open a pull request.