Last active
July 13, 2021 10:50
-
-
Save monnoval/748685731256ef1f4cfa8952a9f8ac46 to your computer and use it in GitHub Desktop.
xkeysnail-config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Run in startup using | |
# /usr/local/bin/xkeysnail /home/msnoval/.xkeysnail-config.py --devices /dev/input/event4 /dev/input/event7 --quiet | |
# | |
# Run xkeysnail without sudo, https://github.com/mooz/xkeysnail/issues/64#issuecomment-600380800 | |
# $ sudo groupadd -f uinput | |
# $ sudo gpasswd -a $USER uinput | |
# $ cat <<EOF | sudo tee /etc/udev/rules.d/70-xkeysnail.rules | |
# KERNEL=="uinput", GROUP="uinput", MODE="0660", OPTIONS+="static_node=uinput" | |
# KERNEL=="event[0-9]*", GROUP="uinput", MODE="0660" | |
# EOF | |
import re | |
from xkeysnail.transform import * | |
# [Global modemap] Change modifier keys as in xmodmap | |
define_modmap({ | |
# Kinesis Advantage | |
Key.RIGHT_META: Key.RIGHT_CTRL, | |
Key.LEFT_CTRL: Key.RIGHT_META, | |
# ELECOM 'EX-G WIRED TRACKBALL | |
Key.BTN_SIDE: Key.ENTER, | |
}) | |
# [Conditional modmap] Change modifier keys in certain applications | |
define_conditional_modmap(re.compile('Gvim|nvim-qt'), { | |
Key.RIGHT_META: Key.RIGHT_CTRL, | |
}) | |
# Keybindings for Browsers | |
define_keymap(re.compile("Gvim|nvim-qt"), { | |
# ELECOM 'EX-G WIRED TRACKBALL | |
K("BTN_EXTRA"): K("C-q"), | |
}, "Gvim") | |
# Keybindings for Browsers | |
define_keymap(re.compile("Firefox|firefox|Google-chrome|Chromium|LibreWolf"), { | |
K("C-right"): K("C-TAB"), | |
K("C-left"): K("C-Shift-TAB"), | |
}, "Browsers") | |
# I do not use emacs so this affects all apps | |
define_keymap(lambda wm_class: wm_class not in ("Emacs"), { | |
K("RShift-T"): [launch(["konsole"])], | |
K("RShift-V"): [launch(["nvim-qt"])], | |
# BTN_SIDE | |
# BTN_EXTRA | |
# BTN_FORWARD | |
# BTN_MIDDLE | |
K("BTN_EXTRA"): K("C-w"), | |
K("BTN_FORWARD"): K("C-f7"), | |
K("HOME"): K("C-f9"), | |
}, "All apps") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment