Running I3

I wanted to switch to i3, a tiling window manager. There are some things that are better, and some things that I miss. I run Ubuntu 16.04 LTS and Unity provides a lot of functionality that makes using the computer effortless. The motivation for using i3 is that, while developing, I end up tiling all my windows in separate workspaces anyways. It seems like the natural functionality of i3 better fits my use-case. That means I have to find workarounds for the nice things.

Audio Visual

HDMI Video

This one was relatively easy. arandr provides a graphical interface that lets me mirror or expand desktops when the HDMI is plugged in. This was foolproof. I’ll continue to use it.

HDMI Audio

This part sucks. Unity provides a nice ‘windows-like’ interface to select what you want to output. Pulseaudio presents a list of ‘sources’ and ‘sinks’ that are esoteric to understand at best. I am still not confident that I understand how mapping these work.

I settled on not modifying the default system output when the HDMI Audio output is available. Instead, within the program I am concerned with, I will select which audio output device I want to use.

Ponymix appears to be a solution to this problem. It is a command line utility that aims to make the modification of pulseaudio configurations easier. But the documentation is lacking, and I find it very difficult to use. I hate it now.

pavucontrol provides a way to check that the audio device you are concerned about is working. Adjust the volume slider for said device and you should hear bloop coming from it.

AudioPick is a chrome extension that makes it easy to tell chrome to output to the device I want.

Key Remapping

Switch Control and Caps Lock

This one is special because it is an interrupt key I think. Xmodmap is the only way I can get this to work reliably.

You should first capture your current keyboard setup:

xmodmap -pke > ~/.Xmodmap

Then configure .xinitrc to use this map when you login:

echo "xmodmap ~/.Xmodmap" > .xinitrc

Then, at the end of .Xmodmap, include this block:

!
! Swap Caps_Lock and Control_L
!
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L

I think that’s it.

Other keys (media)

Xbindkeys

This is a window manager independent solution. It works really well with i3wm but I’ve yet to try it in Unity. I want to say that Unity can kind of fuck it up because I’ve had trouble with this topic in the past. Either Unity was horrible or I was inexperienced. Both are completely plausible.

As always arch documentation is stellar for this.

Make a blank config file:

xbindkeys -d > ~/.xbindkeysrc

Find a code block that relates to a key press:

xbindkeys -k

Reload the configuration after changing the file:

xbindkeys -p

i3wm Configuration

While xbindkeys works well for a generalized solution, I like the integration aspect of the i3 configuration. If I can determine that xbindkeys works well with Unity, that will be my solution for the future though.

Side Note: The multimedia keys on my keyboard give off codes that are defined by XFree86 keysym codes. A full list of all those symbols is here. When you run xev, you’ll see one of these names in the key press. As as sub-side-note, I like the xbindkeys -k utility more than I like xev. It seems to give me a more concise answer. It opens a new window and ignores the endless mouse events.

I think that the i3 configuration takes precedence over xbindkeys. I tested this by defining mute in my i3 configuration. xbindkeys -k did not pick up on the key press. Eliminating it from the configuration allowed it to work.

Because I might switch back to Unity occasionally (drunk movie watching), I’ll leave the high-priority media keys within the window manager configuration. Other interesting things like script triggers, I’ll put in xbindkeys.

Sample configuration:

#Pulse Audio controls
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 1 +5% #increase sound volume
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 1 -5% #decrease sound volume
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 1 toggle # mute sound

Miscellaneous i3 Configuration

Keybind Screenshot

I use this feature ALL_THE_TIME. It is something I need at my fingertips to communicate effectively while developing. I’ll keep trying to find better solutions, but I think this is the best that I’ve found yet. maim allows me to immediately jump to region selection mode, and then it dumps the image directly in my home directory or to xclip. Mastahpiece 😘👌.

bindsym --release Shift+Print exec --no-startup-id "maim -s -c 1,1,1,0"
bindsym --release Print exec --no-startup-id "maim -s -c 1,1,1,0 --format png /dev/stdout | xclip -selection clipboard -t image/png"

Moneyshot