Custom Key Bindings in i3WM

Custom Key Bindings in i3WM

Shortcut keys save a lot of time and improves productivity. Here is how we can add shortcut keys in i3WM.

svelte logo

Want a Svelte site built? Hire Me.

I have already explained why using a tiling window manager is good for productivity. If you are using an old laptop which isn’t that great at performance then you should try a TWM. It uses the lowest RAM I have seen in any desktop environment.

In my 4GB used ThinkPad, this is the best thing after buying an SSD. Apps run super smooth. The major RAM hungry app I have is VSCode. The computer handles it pretty well. But I make sure not to have too many plugins installed in VSCode.

I use the following method more than others because I use Ubuntu minial on my Thinkpad which sometimes do not support all the shortcut keys. For example, Thinkpad’s dedicated volume control doesn’t work on this minimal setup.

So in order to make this work, we should know what is the keycode of these keys. Here is an easy way to know. Run the below command on terminal.

xev -event keyboard  | egrep -o 'keycode.*)'

This will show two windows. Keep the cursor on the window where a square is shown and click the key on the keyboard you want the keycode for.

get shortcut key name

Once you have the shortcut key name (Menu, Return, Super_L, etc..) you can use this in i3 windows manager configuration file usually located in ~/.config/i3/config

Use VIM or nano to open it

nano ~/.config/i3/config

Now add the following line to the file to create a new shortcut

bindsym XF86AudioLowerVolume exec amixer -q -D pulse sset Master 5%-

Below table describes what’s happening in the above line.

Part of the code Function
bindsym default for binding a key
XF86AudioLowerVolume the keycode for volume down in my Thinkpad
exec execute the command
amixer -q -D pulse sset Master 5%- the command to lower the volume by 5%

Find related articles

Let's discuss on Twitter