Skip to content

SUPERPOWER CAPS LOCK KEY ON LINUX

The caps lock key is probably the most useless button on your keyboard, and arguably the Internet would be a better place without it.

I originally wrote an article on Medium to do this on Mac OS, but I have recently switched to Linux and really missed the functionality.

A great way to use the caps lock key is to turn it into what some call the "hyper key" which is mapping the one caps lock key to a combination of Ctrl+Alt+Super+Shift (where Super is Meta/Cmd/Win)... not to be confused with the actual "Hyper" key if you're using a space-cadet keyboard.

The great thing about this "hyper" key is it allows you to associate new key shortcuts that are unlikely to conflict with other apps. For example, I use HYPER+e to launch VSCode, HYPER+c for my browser, HYPER+t for Terminal, HYPER+arrow keys to move windows between monitors, and so on.

The Linux problem

Mac OS was nice and simple, but for Linux I could not find an easy solution. There are a few ways to do it with X11, but I didn't want to move away from Wayland, so I used KMonad, which seems like one of the few options.

The process of getting it setup isn't complicated, but not it's exactly quick, and you need to know your way around bash profiles or setting up services. These instructions will be based on Ubuntu 24.04 + Wayland GNOME, but should work across distros and desktops.

(1) First you need to install KMonad. The installation instructions are pretty good, but might involve installing stack Haskell project manager (lol), and you might need to add a $PATH, and you need to set the permission correctly (see the FAQ for instructions on these) – don't skip this.

(2) Second, create your configuration file. There's an insanely long tutorial for it, but the TL:DR; is that you need to create an alias (defalias sym C-A-M-sft) and put @sym where the caps lock button is on your layer. You can grab my full configuration file on GitHub, but take note that I also swap my Super and Alt keys to match my Apple keyboard, and I also use a script to load all my keyboards (see below).

(3) If you have multiple keyboards you need to create config files for each.

cp /etc/init.d/kmonad /etc/init.d/kmonad2
cp /etc/kmonad/config.kbd /etc/kmonad/config-epomaker.kbd

The only change to make in the .kbd config is the path to the the device.

#!/bin/bash
# /etc/kmonad/config.kbd
input (device-file "/dev/input/by-id/...

And adjust the service config for each keybaord:

command="/usr/local/bin/kmonad"
command_args="/etc/kmonad/config-epomaker.kbd"
command_background="true"
pidfile="/run/kmonad2.pid"

I used to have bash script that would dynamically load all keyboards, and while that sort of worked most of the time, it didn't play well with OpenRC, and since I'm not switching the physical keyboard itself all that often, manually adding each is more convenient approach.

(4) Finally, you need a way load your configuration file. You could have run kmonad with your configuration file, but you'd need to do that every time you turn on your computer.

# on gentoo openrc
rc-update add kmonad default
rc-update add kmonad2 default
# then start the services, or reboot

You can start KMonad automatically in a number of ways (e.g. adding the command in Settings > Startup applications), but you also add the GNOME Extension KMonad Toggle. Note that I'm specifying my custom script at the bottom, and I've added an & so that the cursor doesn't get stuck on "in progress".

(5) Now for the fun part - you should be able to shortcuts using the caps lock key. When you press it, you should see it show as Ctrl+Alt+Super+Shift 🎉 !!

Comments