X Class name In And Out
Transform one key press in to another for specific X windows only.
Some applications have horrible keybindings and no way to configure them.
Our only hope is to make the good keybindings produce the bad keybindings.
Remaps are defined in xciao.c
You need to supply the class name of the window, the key you want to press (Inputs) and the keys you want to produce for that class name (Outputs).
If you are familiar with dwm, you will recognize the key naming conventions.
- ControlMask -> Control
- Mod1Mask -> Alt
- Mod4Mask -> Super/Hyper/Windows
/* xciao.c */
static Remap remaps[] = {
/* Class | Input mask | Input key | Output mask | Output key */
{"Chromium", "ControlMask", "j", "ControlMask", "Prior"}, /* Control-j -> Previous tab */
{"Chromium", "ControlMask", "k", "ControlMask", "Next"}, /* Control-k -> Next tab */
{"Chromium", "ControlMask", "h", "Mod1Mask", "Home"}, /* Control-h -> Home page */
{"Chromium", "ControlMask", "d", "", "Next"}, /* Control-d -> Page down */
{"Chromium", "ControlMask", "u", "", "Prior"}, /* Control-u -> Page up */
{"Chromium", "ControlMask", "bracketleft", "Mod1Mask", "Left"}, /* Control-[ -> Backwards history */
{"Chromium", "ControlMask", "bracketright", "Mod1Mask", "Right"}, /* Control-] -> Forwards history */
{"Chromium", "Mod1Mask", "h", "", "Left"}, /* Alt-h -> Left arrow key */
{"Chromium", "Mod1Mask", "j", "", "Down"}, /* Alt-j -> Down arrow key */
{"Chromium", "Mod1Mask", "k", "", "Up"}, /* Alt-k -> Up arrow key */
{"Chromium", "Mod1Mask", "l", "", "Right"}, /* Alt-l -> Right arrow key */
};
You will need xlib header files and make.
Compile with:
make
Install with
make install
Sxhkd is an easy way to map commands to keys.
Simply pass xciao the key you’re using to trigger the xciao command.
# sxhkd
# Previous tab
control + j
xciao "ControlMask" "j"
# Next tab
control + k
xciao "ControlMask" "k"
# Forward history
control + bracketleft
xciao "ControlMask" "bracketleft"
# Backwards history
control + bracketright
xciao "ControlMask" "bracketright"
...
Start sxhkd
sxhkd -c path/to/xciao/sxhkd
In the context of using xdotool with sxhkd, xdotool very often requires a vast array of hacks/workarounds to work. sleep 0.2, –delay, –clearmodifiers, spamming the keys, @release. These workarounds can even be application and monitor dependent.
In regards to browsers, extensions have a number of limitations that native keybindings do not.
- Loading pages block extensions.
- Extensions are unavailable on some pages.
- Downloads
- History
- File
- Extensions (ironically)
Gonzaru ‘no patch’ DWM functions: Excellent resource for dwm and xlib programming.