Skip to content

Strix007/wsl

Repository files navigation

Arbab Khan’s Dotfiles

WSL Configuration Of Arbab Khan

This is my WSL configuration for my arch WSL instance.

Table of Contents

Caution

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.

About

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.

What To Install

Windows 11

WSL

Shell

Tmux

NeoVim

lf

fzf

MPD

Emacs

Under WSLg, you would need to compile emacs yourself with 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 install

Setup Instructions

Windows

WezTerm

To 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.

VcXsrv

Firewall

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.

Startup

To automatically start VcXsrv on startup, move the Windows/config.xlaunch file to the %AppData%\Microsoft\Windows\Start Menu\Programs\Startup directory and enable it in TaskManager

Blurry Fonts

If you experience blurry fonts, follow this answer.

Shortcut

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/"

ArchWSL

Systemd

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.

Emacs Daemon

To enable Emacs daemon on WSL, we need to create a systemd user service for the Emacs daemon. We can do so by the following steps.

Create a service unit file for the Emacs daemon

vim ~/.config/systemd/user/emacs.service

Add the following content to the file

[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

Reload systemd user manager

systemctl --user daemon-reload

Enable the systemd user manager

systemctl --user enable emacs.service

Contributing

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.