Skip to content
/ xciao Public

Turn one key press in to another for a specific X window

License

Notifications You must be signed in to change notification settings

DAFF0D11/xciao

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Xciao

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.

Setup

Create remaps

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 */
 };

Compile

You will need xlib header files and make.

Compile with:

make

Install

Install with

make install

Map xciao to keys

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

What about…

Xdotool

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.

sxhkd xdotool issues

Extensions

In regards to browsers, extensions have a number of limitations that native keybindings do not.

  1. Loading pages block extensions.
  2. Extensions are unavailable on some pages.
    • Downloads
    • History
    • File
    • Extensions (ironically)

Resources

Gonzaru ‘no patch’ DWM functions: Excellent resource for dwm and xlib programming.

About

Turn one key press in to another for a specific X window

Topics

Resources

License

Stars

Watchers

Forks