a working i3 setup for WSL
i3wm: my personal DOOM
as a corollary to the popular "does it run DOOM?" challenge, i like to do sonmething similar with a particular program, the i3 window manager. of course, over time you do begin to get tired of the somewhat rigorous process to build and install i3 and the necessary libraries and dependencies, so naturally i started to think about automating this process.
on face this might seem odd: i3 is avaliable in almost every major linux distro's main app packaging system. what gives?
- Gaps. It's hard to explain until you've used it - by default the i3 window tiling takes up the entirety of the desktop screen, when in tiling mode. The gaps fork adds a simple twist: a configurable method to create 'gaps' or open space between the windows, allowing a little bit of desktop to poke through.
- This feature is usually implemented alongside the compton window compositor, where the user can add a 'shadow' effect that makes each open window pop out very stylishly.
- Compatibility. Recent versions of
i3-wmpackages from the
aptrepository seem to break on WSL X servers. However, I came across a [post] where it was mentioned that the
fdf5d3acommit of the Airblader fork is the most recent, non-breaking, commit for the sourcecode.
copying this script into a file and giving it permissions with
chmod +x foo.sh will perform an automated installation of a wsl-compatible i3 fork, along with the picom compositor.
# ubuntu install for i3 echo "alright, let's do this!" sleep 1s echo "grabbing the Airblader fork of i3, commit @fdf5d3a..." mkdir -p $HOME/gits && cd $HOME/gits git clone https://github.com/Airblader/i3 $HOME/gits/i3-gaps echo "grabbing the files needed to compile library xcb-util-xrm..." sleep 1s git clone https://github.com/Airblader/xcb-util-xrm $HOME/gits/xcb-util-xrm echo "setting commit..." cd $HOME/gits/;i3-gaps && git checkout fdf5d3a sleep 1s echo "let's grab some deps, brah." sleep 1s # deps # ---- sudo apt install -y libxcb1-dev libxcb-keysyms1-dev libpango1.0-dev libxcb-util0-dev libxcb-icccm4-dev libyajl-dev libstartup-notification0-dev libxcb-randr0-dev libev-dev libxcb-cursor-dev libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev autoconf xutils-dev libtool echo "boutique dep creation..." sleep 1s cd $HOME/gits/xcb-util-xrm && git submodule update --init $HOME/gits/xcb-util-xrm/autogen.sh --prefix=/usr echo "alright let's make this bitch" sleep 1 make -j8 echo "wasnt that fun? now shove all that down your pc's gaping software hole" sleep 1s sudo make install echo "now let's run the drill again, with gapped i3" sleep 1s cd $HOME/gits/i3-gaps && autoreconf --force --install rm -rf $HOME/gits/i3-gaps/build && mkdir $HOME/gits/i3-gaps/build cd $HOME/gits/i3-gaps/build && $HOME/gits/i3-gaps/configure --prefix=/usr --sysconfdir=/etc --disable-sanitizers make sudo make install echo "and there you have it. before launching i3, make sure to run X410 or VcXsrv.exe on the windows side." # manual compile for a needed dep # ------------------------------ # mkdir tmp # cd /tmp # git clone https://github.com/Airblader/xcb-util-xrm # cd xcb-util-xrm # git submodule update --init # ./autogen.sh --prefix=/usr # make # sudo make install # i3 build # -------- # i3-gaps-rounded: # git clone https://github.com/resloved/i3 # i3-gaps: # git clone https://www.github.com/Airblader/i3 i3-gaps # cd i3-gaps # git checkout gaps && git pull # autoreconf --force --install # rm -rf build # mkdir build # cd build # ../configure --prefix=/usr --sysconfdir=/etc --disable-sanitizers # make # sudo make install # extras # ------ # sudo apt-get install wget ranger mediainfo highlight tmux calcurse newsbeuter moc qutebrowser imagemagick transmission-cli atool xcompmgr blender pinta gimp markdown mupdf evince audacity vim-latexsuite rsync syncthing cups screenfetch scrot unzip unrar biber ntfs-3g deepin-terminal zip irssi unzip
you will need to setup for windows-side X server, which is outside the scope of this post, but there are plenty of simple guides to get you going. in your shell rc file, you will want to define relevant variables like
DISPLAY. i use this nifty piece of code so i can use my universal shell rc file without having to tweak it manually when i use it with WSL:
if [[ "$(</proc/version)" == *Microsoft* ]] 2>/dev/null; then export WSL=1 export DISPLAY=localhost:0 export NO_AT_BRIDGE=1 export LIBGL_ALWAYS_INDIRECT=1 fi
with a minimal amount of tweaking, this script can serve as the basis for a far more universal way to setup your preferred fork of i3. i will be coming back to this post at some point to add a list of popular forks and list the standout features and possible pros/cons depending on usecase.
the fastest way to use it just about everywhere except WSL, simply removing the specific commit hash from the
git clone command will leave you with a current codebase to build from.
perhaps you're reading this as a relative newcomer to the linux world, looking to jazz up your WSL install. if so, i can guarantee that this script would be a nice piece of code to poke through, because i myself am at best on the lower-end of intermediate-level when it comes to the keyboard-mashing and coding. this means the commands are basically the same basic commands that are important ones to learn when first starting out - i have simply chained them together in more complex ways, and reading through should help you in the quest to understand the ins and outs of shellscripting, as well as the general rhythm and rhyme of programming languages of all varieties.