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 to build a Svelte/SvelteKit site? 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.

I have a ThinkPad laptop with 4GB of memory and using a tiling window manager along with an SSD has made my apps run really smoothly. The app that uses the most memory is VSCode, but my computer can handle it well as long as I don’t have too many plugins installed.

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