hk allows temporary X11 hotkeys to be set. Its usage is:
hk [-w] <hotkey> <command> [<argument> ...]
where <hotkey>
is of the form [Modifier1[+Modifier2[+...]]+]<Key>
. For example:
hk Ctrl+Shift+F6 notify-send "Hello"
will execute the command notify-send "Hello"
when
Ctrl+Shift+F6
is pressed. hk exits as soon as the
command has executed.
hk passes through stdin unchanged so you can pipe input to commands e.g.:
uname | hk Ctrl+F8 xargs notify-send
By default, hk executes the command as soon as the hotkey sequence
is pressed. The -w
option makes hk wait until all
keys (not just the hotkeys) have been released. This can be useful if the
action of the command can be effected by key presses. For example if you use
xdotool
type to enter text on a hotkey, then having the Ctrl key held down can
have surprising effects which -w
can alleviate:
uname | hk -w Ctrl+F8 xdotool type --file -
Latest release: hk-0.3.0 (2023-01-03)
Ignore the Mode Switch key (similarly to Caps Lock et al.).
Ignored modifiers are now also ignored by-w
. On some setups, some modifiers
are permanently set as “pressed” (in some cases, without the user being aware
of it), meaning that they cause -w
to permanently block unless they are
ignored.
Repository (issues, PRs, etc.)
Man pages for the latest release: