How I Switch Between Dark and Light Terminals With I3 and St

in linux

I’m pretty happy with my current Linux desktop environment - I’m running Arch Linux, which is a barebones, simplicity-first do-it-all-yourself distribution. I’m using the absolutely amazing i3 tiling window manager, and I just recently switched to a fairly hacked-on version of the st terminal emulator, which is basically as stripped-down and simple as terminal emulators get.

I’ve got two versions of st compiled and sitting in /usr/bin - one with the dark version of the Solarized color scheme, and one with the light version. I’ve got a couple of scripts that I wrote to easily switch between those two, which I do based on the whims of my corneas.

First, I’ve got this script that writes a basic boolean to a dotfile in my home folder:

if [ "$(< $FILE)" = 't' ]; then
echo 'f' > $FILE
echo 't' > $FILE

And then I’ve got this script which I use to actually launch the terminal emulators themselves:

if [ "$(< ~/.term_dark)" = 't' ]; then
exec /usr/local/bin/st-dark $@
exec /usr/local/bin/st-light $@

I have the first launch on $mod+Backspace in i3, and the second launch using the default $mod+Enter. Here’s what that config looks like

bindsym $mod+BackSpace exec /home/smith/bin/
bindsym $mod+Return exec /home/smith/bin/ -e tmux

As an aside, here’s the command I used to get those snippets off my filesystem while editing this post in vim:

:r !grep -i backspace ~/.i3/config
:r !grep -i ~/.i3/config