mooz / xkeysnail

Yet another keyboard remapping tool for X environment
900 stars 112 forks source link

Second keyboard #60

Open Dmunch04 opened 4 years ago

Dmunch04 commented 4 years ago

Does this have support for a second keyboard? So it can tell the difference between the two

Lenbok commented 4 years ago

conditional_modmap (and conditional_multipurpose_map from #52) support device name, so you can do like this snippet from my config:

# The next global modmap and multipurpose modmap are just when
# using non QMK keyboards, in my case Microsoft Natural.
# [Global modemap] Change modifier keys as in xmodmap
define_conditional_modmap(lambda wm_class, device_name: device_name.startswith("Microsoft"), {
   Key.RIGHT_ALT: Key.RIGHT_CTRL
})

or (needs #52):

# [Multipurpose modmap] Give a key two meanings. A normal key when pressed and
# released, and a modifier key when held down with another key.
define_conditional_multipurpose_modmap(lambda wm_class, device_name: device_name.startswith("Microsoft"), {
   # Capslock is tab when pressed and released.
   # Control when held down.
   Key.CAPSLOCK: [Key.TAB, Key.LEFT_CTRL],

   # Tab is grave when pressed and released.
   # Win/Super when held down.
   Key.TAB: [Key.GRAVE, Key.LEFT_META],

   # Left shift is open paren when pressed and released.
   # Left shift when held down.
   Key.LEFT_SHIFT: [Key.KPLEFTPAREN, Key.LEFT_SHIFT],

   # Right shift is close paren when pressed and released.
   # Right shift when held down.
   Key.RIGHT_SHIFT: [Key.KPRIGHTPAREN, Key.RIGHT_SHIFT]
})

I don't think the other keymap functions support using the device name but it would probably not be that hard to add that.

joshgoebel commented 2 years ago

My fork now fully supports device_name conditionals for both keymaps and modmaps.

https://github.com/joshgoebel/keyszer