Coder Social home page Coder Social logo

zsugabubus / interception-k2k Goto Github PK

View Code? Open in Web Editor NEW
52.0 5.0 10.0 86 KB

Configurable plugin for Interception Tools (caps2esc, space2meta, tab2altgr...)

License: GNU General Public License v3.0

Makefile 3.00% C 97.00%
evdev uinput xcape keyboard-shortcuts interception-tools

interception-k2k's People

Contributors

senchopens avatar zsugabubus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

interception-k2k's Issues

changing key up/down order for tapping

I have a keyboard where the right control key is at the position of the ' key (to the right of the ; key), so I configured it this way:

{ .base_key = KEY_RIGHTCTRL, .tap_key = KEY_APOSTROPHE, .repeat_key = KEY_RIGHTCTRL, .hold_key = KEY_RIGHTCTRL },

It works great, but when I type too fast, I get a CTRL-a instead of a 'a. I think the problem is that I do this: CTRL down, a down, CTRL up, a up (I don't think it's a question of delay). Is it possible in that case to generate the tap event?

By the way, what is the difference between repeat_key and hold_key? I tried setting hold_key to apostrophe, and now getting the CTRL key to work as CTRL requires waiting quite a while. I while try using shorter repeat settings to see if that helps.

broken configuration for multitple keyboards

I have the following configuration:

- JOB: "intercept -g $DEVNODE | /opt/interception/interception-ergo | uinput -d $DEVNODE"
  DEVICE:
    NAME: "TrulyErgonomic.com Truly Ergonomic Computer Keyboard"
    EVENTS:
      EV_KEY: [KEY_CAPSLOCK, KEY_ESC]
- JOB: "intercept -g $DEVNODE | /opt/interception/interception-dell | uinput -d $DEVNODE"
  DEVICE:
    NAME: "AT Translated Set 2 keyboard"
    EVENTS:
      EV_KEY: [KEY_CAPSLOCK, KEY_ESC]

with the following tap-rules.h.in for dell

{ .base_key = KEY_CAPSLOCK, .tap_key = KEY_ESC, .repeat_key = KEY_LEFTCTRL, .hold_key = KEY_LEFTCTRL },
{ .base_key = KEY_APOSTROPHE, .tap_key = KEY_APOSTROPHE, .repeat_key = KEY_RIGHTCTRL, .hold_key = KEY_APOSTROPHE },

and for the ergo external keyboard

{ .base_key = KEY_CAPSLOCK, .tap_key = KEY_ESC, .repeat_key = KEY_LEFTCTRL, .hold_key = KEY_LEFTCTRL },
{ .base_key = KEY_RIGHTCTRL, .tap_key = KEY_APOSTROPHE, .repeat_key = KEY_APOSTROPHE, .hold_key = KEY_RIGHTCTRL },

Everything works with the internal dell keyboard, but it does not with the ergo one: I get an unconditional ESC on the caps lock key, and ' on the right control key (even when holding the key). Did something change when you introduced the tapping rules?

How do you use it?

I tried using this plugin, and I cannot make it work. Here is what I did:

make CONFIG_DIR=example
make CONFIG_DIR=example install

then I edited /etc/udevmon.yaml to be

- JOB: "intercept -g $DEVNODE | /opt/interception/interception-pipe0 | uinput -d $DEVNODE"
  DEVICE:
    EVENTS:
      EV_KEY: [KEY_CAPSLOCK, KEY_ESC]

and I finally did sudo systemctl restart udevmon.service

What I observe:

  • caps lock is bound to ctrl_l, even by itself
  • escape stays escape
  • ctrl_l is bound to caps lock

According to https://gitlab.com/interception/linux/plugins/caps2esc/issues/9#note_202408489 it should work out of the box. Am I doing something wrong?

Shift + Esc to Tilde Character?

I'm trying to put together an inception-k2k rule for my 65% keyboard to get shift+escape bound to the ~ character. My keyboard doesn't have a grave/tilde key, but I use tilde quite often sicne it's the *nix shortcut for home directory. I figured this would be relatively straightfoward, but it turns out that it's made complicated by the fact that ~ isn't a key - it's a character that gets printed when Shift+` is typed.

Based on what I've read from the source code, it doesn't seem possible to write a multibind that targets another multibind, like

{ .keys = { KEY_SHIFT, KEY_ESCAPE }, PRESS_ON_DOWN(KEY_SHIFT, KEY_GRAVE), DOWN_IFF_ALL_DOWN(2) }

The other thought I had was that perhaps I could leverage an external tool to write the character for me, but it appears that we don't have any support for doing something like ydotool calls (the wayland compatible variant of xdotool) in response to keybind being pressed.

Any thoughts on how I could accomplish this particular binding?

Not working on Anne Pro 2

Hi there! I just got my Anne Pro 2 today and it looks like interception-k2k doesn't work. I use KDE as my DE. It works, when i set up capslock to act as another ctrl-key in KDEs settings.

I already tried to run xev to see the difference a keypress makes. Pressing capslock on the Anne Pro 2 registers as:

KeyPress event, serial 40, synthetic NO, window 0x9e00001,
    root 0x7c9, subw 0x0, time 893793, (-130,-199), root:(1061,432),
    state 0x10, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyRelease event, serial 40, synthetic NO, window 0x9e00001,
    root 0x7c9, subw 0x0, time 893945, (-130,-199), root:(1061,432),
    state 0x12, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

Whereas on my Logitech K800 or integrated Laptop keyboard (Thinkpad x1 Carbon 5th gen) it looks like this:

KeyPress event, serial 40, synthetic NO, window 0x9e00001,
    root 0x7c9, subw 0x0, time 973512, (-171,149), root:(1020,780),
    state 0x10, keycode 9 (keysym 0xff1b, Escape), same_screen YES,
    XLookupString gives 1 bytes: (1b) "
mbLookupString gives 1 bytes: (1b) "
FilterEvent returns: False

KeyRelease event, serial 40, synthetic NO, window 0x9e00001,
    root 0x7c9, subw 0x0, time 973512, (-171,149), root:(1020,780),
    state 0x10, keycode 9 (keysym 0xff1b, Escape), same_screen YES,
    XLookupString gives 1 bytes: (1b) "
FilterEvent returns: False

When i systemctl stop udevmon and press capslock again on the Logitech-keyboard, it looks like this:

KeyPress event, serial 42, synthetic NO, window 0x7200001,
    root 0x7c9, subw 0x0, time 1052591, (318,205), root:(1509,836),
    state 0x12, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyRelease event, serial 42, synthetic NO, window 0x7200001,
    root 0x7c9, subw 0x0, time 1052691, (318,205), root:(1509,836),
    state 0x12, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

Can you help me out there? I don't know if this is a bug that should be fixed or just an issue on my side.

I will happily provide additional information when needed. Thanks for a great tool.

Decreasing delay of a tap remap

Thank you for this very useful software, I am using it with Sway for some of my key remaps and its working really nicely.

I have the basic 'caps2esc' behaviour in my config:

{ .base_key = KEY_CAPSLOCK, .tap_key = KEY_ESC, .repeat_key = KEY_LEFTCTRL }

This is working great, however I notice (using wev/xev) that when the .base_key is pressed, there is an added delay between the physical press of the .base_key (Caps) and the registered .base_key (Caps) downpress in xev.
This sometimes causes the unintended behaviour of the modifer key being sent AFTER the key I want to be modified.

This only happens when I press both keys (Caps + N for example) in quick succession.

For example:
Caps n ....becomes.... n Caps
or
Caps LeftMouse ...becomes... LeftMouse Caps

So I have been retraining myself to wait a few milliseconds longer before hitting the next key :D

Is there a way to reduce the delay between the physical keypress and the downpress being registered?

KEY_SPACE and HJKL into ARROWS

My setup

Thank you for writing and sharing this piece of code. I tried to read into it, and find it a bit confusing, so I'm asking for your kind help. :)

I'm on Arch on Wayland with SwayWM. I'm using latest AUR for interception-tools and evtest.

/etc/interception/udevmon.d/keymod.yaml:

- JOB: "intercept -g $DEVNODE | /opt/interception/maricn | uinput -d $DEVNODE"
  DEVICE:
    EVENTS:
      EV_KEY: [KEY_CAPSLOCK, KEY_ESC, KEY_SPACE]

/etc/udevmon.yaml:

# - JOB: "intercept -g $DEVNODE | uinput -d $DEVNODE"
#   DEVICE:
#     NAME: "AT Translated Set 2 keyboard"

Problem 1 - can't run make test

Hi, I would like to run tests, but make always throws errors...

nikola@work-x1c-arch ~/T/interception-k2k (master *+)» sudo env CONFIG_DIR=/home/nikola/Tools/interception-k2k/maricn make test
[sudo] password for nikola:
CFLAGS=-DVERBOSE make
make[1]: Entering directory '/home/nikola/Tools/interception-k2k'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/nikola/Tools/interception-k2k'
make install
make[1]: Entering directory '/home/nikola/Tools/interception-k2k'
# If you have run `make test` then do not forget to run `make clean` after. Otherwise you may install with debug logs on.
install -D --strip -t /opt/interception out/multi-rules.h.in out/tap-rules.h.in
install: strip process terminated abnormally
install: strip process terminated abnormally
make[1]: *** [Makefile:29: install] Error 1
make[1]: Leaving directory '/home/nikola/Tools/interception-k2k'
make: *** [Makefile:34: test] Error 2

Instead I do this to run tests (albeit w/o debug output):

make clean && make && sudo make install && sudo systemctl restart udevmon.service

Problem 2 - space + home row => arrows

I want to make my space key pressed with home row keys emulate arrows. I tried:

  • multi-rules with KEY_SPACE and K mapping into PRESS(KEY_UP), but I can't make KEY_SPACE stop repeating on other key down/up (space + k keeps repeating space long after i release k)
  • tap-rule which maps KEY_SPACE into KEY_RIGHTMETA and then multi-rules that map KEY_RIGHTMETA with K into arrow up.. but then meta + k seems to have precedence, which is mapped with my tiling WM..
  • tap-rule which maps KEY_SPACE into itself with .repeat_key = KEY_RESERVED and multi-rule that maps KEY_SPACE with K into an arrow.. this doesn't change anything..

My interception-k2k/maricn/multi-rules.h.in:

/* space + nums => F-keys */
{ .keys = { KEY_SPACE, KEY_1 }, PRESS(KEY_F1), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_2 }, PRESS(KEY_F2), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_3 }, PRESS(KEY_F3), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_4 }, PRESS(KEY_F4), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_5 }, PRESS(KEY_F5), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_6 }, PRESS(KEY_F6), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_7 }, PRESS(KEY_F7), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_8 }, PRESS(KEY_F8), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_9 }, PRESS(KEY_F9), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_0 }, PRESS(KEY_F10), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_MINUS }, PRESS(KEY_F11), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_EQUAL }, PRESS(KEY_F12), DOWN_IFF_ALL_DOWN(2) },

/* space + home row => arrow keys */
{ .keys = { KEY_SPACE, KEY_H }, PRESS_ON_DOWN(KEY_LEFT), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_K }, PRESS_ON_DOWN(KEY_UP), DOWN_IFF_ALL_DOWN(2), .repeated_key = KEY_RESERVED},
{ .keys = { KEY_SPACE, KEY_J }, PRESS_ON_DOWN(KEY_DOWN), DOWN_IFF_ALL_DOWN(2) },
{ .keys = { KEY_SPACE, KEY_L }, PRESS_ON_DOWN(KEY_RIGHT), DOWN_IFF_ALL_DOWN(2) },

My interception-k2k/maricn/multi-tap.h.in:

/* caps2esc */
{ .base_key = KEY_CAPSLOCK, .tap_key = KEY_ESC, .repeat_key = KEY_LEFTCTRL, .hold_key = KEY_LEFTCTRL, .hold_immediately = 1 },

{ .base_key = KEY_SPACE, .tap_key = KEY_SPACE, .repeat_key = KEY_RESERVED, .hold_key = KEY_RESERVED, .hold_immediately = 1 },

Problem 3 - stuck letters

Sometimes when I load interception plugin, my letter J gets stuck and doesn't output.. It doesn't get registered in evtest and when I move to another window (firefox) it keeps outputting j until i press some other key.

Map to key + modifiers

Is it possible to map for example caps+w to ctrl+w without remapping caps to ctrl for all keys?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.