mooz / xkeysnail

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

PRINT key not working in Modmap #153

Closed DidacGit closed 2 years ago

DidacGit commented 2 years ago

First of all thanks for the amazing package, it literally feels like using Emacs everywhere. Specially due to the mark-setting commands.

The problem that I'm experiencing is that mapping the PRINT key to any other key doesn't work, as in:

define_modmap({
    Key.PRINT: Key.RIGHT_ALT,
})

I've tried mapping it to other keys but still doesn't work. Also, I've successfully mapped other keys using the same method (e.g. RightAlt to RightCtrl).

I've tested with two different keyboards: the built-in from the Thinkpad T14s and an external Bluetooth Thinkpad keyboard.

Thanks a lot

jvasile commented 2 years ago

@DidacGit I haven't dug into xkeysnail on this topic, but I do this after I start xkeysnail to turn PrtSc into a menu key:

 xmodmap -e "add mod4 = Print"

For right alt, I would do:

 xmodmap -e "add mod1 = Print"

Perhaps that helps you.

DidacGit commented 2 years ago

I actually already have my favorite setup using xmodmap:

! Turn, at the right of the Spacebar: ALT - PRINT - CTRL
! Into: CTRL - ALT - PRINT

! Remove the two modifier keys first from the modifier map.
remove mod5 = ISO_Level3_Shift
remove Control = Control_R

! Change the keys from the global map.
keycode 108 = Control_R
keycode 107 = ISO_Level3_Shift
keycode 105 = Print

! Add again the modifier keys.
add mod5 = ISO_Level3_Shift
add Control = Control_R

But I cannot make it work with xkeysnail. When I run one before the other it stops working and vice versa. EDIT: Even if I don't use define_modmap with xkeysnail, just one define_keymap statement.

DidacGit commented 2 years ago

In the end it turns out that the PRINT key in the Thinkpad Wireless keyboard is named Key.SYSRQ instead of Key.PRINT. So changing it worked.

097115 commented 1 year ago

@DidacGit

Considering that thinkPad's Print Screen aka SYSRQ key, how does your final config entry looks after all?

I tried something like:

define_keymap(re.compile(".*"), {
    Key.SYSRQ: Key.RIGHT_ALT,
    K("LSuper-Q") : K("Alt-F4"),
    K("RAlt-SPACE") : K("LSuper-SPACE"),
    K("RShift-SYSRQ"): K("SYSRQ"),
})

But while other mappings work, the very first one fails (my ThinkPad PrtSc button still acts like Print Screen when pressed alone or with some other key).

joshgoebel commented 1 year ago

For remapping keys, not combos, use modmap.

097115 commented 1 year ago

@joshgoebel, I swear I tried that before, too, and it didn't work (probably had some stupid mistake in the config...)

Thanks for insisting on the right solution :) (Even better, I ended with multipurpose_modmap, and what an excellent app xkeysnail is!)