CopyQ on CapsLock

CopyQ on CapsLock

July 27, 2024

Remapping CapsLock to run Kmonad Script #

Let’s say we want to deactivate the physical CapsLock Button, causing it to no longer send the keycode 66. In Gnome we can do that using the Gnome Tweak Tool for example. Because I want to toggle my Clipboard Manager Window by hitting the CapsLock Button to open up CopyQ I was looking for a solution I could use with Wayland. Thankfully I found Kmonad After some fiddeling around I managed to understand how to set it up, you can do a lot more compared to my simple task of binding a shell script to a Button on my Keyboard. So here are my config files:

Kmonad keymap file #

We can use this file as a template.

(defcfg
    input  (device-file "/dev/input/by-id/my-keyboard-kbd")
    output (uinput-sink "kmonad")
    fallthrough true
    allow-cmd true
)



(defsrc
  grv  1    2    3    4    5    6    7    8    9    0    -    =    bspc
  tab  q    w    e    r    t    y    u    i    o    p    [    ]    \
  caps a    s    d    f    g    h    j    k    l    ;    '    ret
  lsft z    x    c    v    b    n    m    ,    .    /    rsft
  lctl lmet lalt           spc            ralt rmet cmp  rctl
)

(defalias 
    clp (cmd-button "su alex -c '/usr/bin/copyq toggle'")
)

(deflayer qwerty 
  _    _    _    _    _    _    _    _    _    _    _    _    _    _
  _    _    _    _    _    _    _    _    _    _    _    _    _    _
  @clp    _    _    _    _    _    _    _    _    _    _    _    _
  _    _    _    _    _    _    _    _    _    _    _    _
  _    _    _              _              _    _    _    _
)

Kmonad Systemd Unit File #

We need this to run the service after logging into our Gnome Desktop Environment. Again we can use the example provided by Kmonad.

[Unit]
Description=kmonad keyboard config

[Service]
Restart=always
RestartSec=3
ExecStart=/usr/bin/kmonad %E/kmonad/%i.kbd
Nice=-20

[Install]
DefaultInstance=config
WantedBy=default.target

This website was helpful with additional information about the systemd unit file.

Now what? #

I can now use my Clipboard Manager CopyQ by hitting CapsLock to show the Clipboard History.