timmymayes · 2022-07-11 16:44
I use a QMK keyboard with thumbclusters and as such I want to use Super and Hyper keys as extra modifiers for bindings in emacs.
Super is default defined as the windows key and I have the APP key setup to be hyper via xmod:
keycode 135 = Hyper_L NoSymbol Hyper_L
I test this via using the global-set-key command interactively and when I press H-d emacs shows s-d
I do dual boot and used Xah's tutorial for setting up the app key as hyper in windows ([link](http://xahlee.info/emacs/emacs/emacs_hyper_super_keys.html)) and it works without issue. I'm not concerned with making super work in windows as I am working towards 100% linux usage.
Any ideas?
​
## Output when pressing ALT ##
KeyRelease event, serial 37, synthetic NO, window 0x2400001,
root 0x1f2, subw 0x0, time 2951868, (604,430), root:(2094,517),
state 0x8, keycode 108 (keysym 0xffea, Alt_R), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
## OUTPUT WHEN PRESSING App/Hyper##
KeyPress event, serial 37, synthetic NO, window 0x2400001,
root 0x1f2, subw 0x0, time 2953012, (604,430), root:(2094,517),
state 0x0, keycode 135 (keysym 0xffed, Hyper_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
## OUTPUT WHEN PRESSING win/super
KeyRelease event, serial 37, synthetic NO, window 0x2c00001,
root 0x1f2, subw 0x0, time 5611274, (1139,149), root:(2629,236),
state 0x40, keycode 133 (keysym 0xffec, Super_R), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
ieure · 2022-07-11 17:54
xev agrees that the key is Hyper, so I'm not sure what to tell you. As far as I know, Emacs on X respects the X modifier bits and doesn't have variables to control which key is what modifier, like it does on other platforms.
A thing I've noticed is that programs which have launched prior to a keymap change sometimes retain the old keymap. Maybe you're running `xmodmap` after Emacs has started?
It's a dark and horrible system, but I do recommend using XKB over `xmodmap` these days. If you want to go that route, [I made a Debian package of my bindings](https://gitlab.com/ieure/xkbsucks), which includes a giant README that explains XKB as best I understand it. It finally works exactly how I want: I can have internal & external keyboards with different keymaps, and keyboards get the correct map configured whenever they're plugged in. It's probably not right for you, but is a good jumping-off point for customization, since it does everything you want *except* have your exact key remappings, and actually explains how the heck XKB works, which none of the official documentation bothers with at all.
timmymayes · 2022-07-11 18:15
I'm at work atm but I'll look into this thank you.
Can confirm i've exited and reloaded emacs around tweaks/changes to the same issue. I'm not using a daemon either.
Appreciate you taking the time to answer and pass me a potential solution!
ambihelical · 2022-07-12 01:41
The first line of your readme is pure gold.
"The xkb extension is the worst piece of essential Linux software that wasn’t written by Lennart Poettering."
timmymayes · 2022-07-12 02:06
Think I solved it.
I found a random config that talked about various caps lock rebinds and the way they setup hyper in it is as below (apps key & keycode is actually my app key not caps lock but the method worked)
my xmod set the app key to nabla
! appskey -> Nabla
keycode 135 = nabla
then in my config the following. I'm assuming \[8711\] is whatever the nabla key event is.
(define-key key-translation-map [8711] 'event-apply-hyper-modifier)
ieure · 2022-07-12 02:32
Interesting, I didn't know about `key-translation-map`.
FWIW, I've used Hyper as a modifier for personal Emacs bindings on Linux for ages, and I've never had to mess with that. I'm not sure why you'd need it.
timmymayes · 2022-07-12 03:15
Turns out the key-translation-map method was not so good. When I'd hold the key it would send H but after key delay would then send the original code. Seeming like the key was sending so fast it was overriding the event translation.
This made me poke at it some more and I realized my actual mistake. Didn't realize I needed to clear mod, add mod. This solved it. Now I have it setup properly.
So this code fixed it. (largely replying with the fix in case anyone else ends up where I was maybe they find this fix)
clear mod3
keycode 135 = Hyper_L
add mod3 = Hyper_L
_viz_ · 2022-07-12 03:32
Thank you very much for the writeup! I gave up immediately when I saw the really adequate documentation for xkb Nix module [1], when I'm feeling brave and courageous, I will try to rewrite the xmodmap nonsense to xkb.
1. https://nixos.org/manual/nixos/stable/options.html#opt-services.xserver.extraLayouts
P.S.
>The xkb extension is the worst piece of essential Linux software that wasn’t written by Lennart Poettering.
Not exactly essential software, but *cough* GNOME *cough*?
ieure · 2022-07-12 04:15
Ah, yeah. I've run into that before, but generally Emacs will report multiple bits being held down, like `H-s-d`.
CorysInTheHouse69 · 2022-07-12 05:31
What keyboard is in the picture?
L-Szos · 2022-07-12 15:03
Its a symbolics lisp machine keyboard i believe.
_viz_ · 2022-07-20 06:58
Good sire, I believe I defeated the formidable enemy. Here is how I printed the pc102-de and pc105-uk keyboards
% setxkbmap gb -option -geometry 'pc(pc105)' -print |xkbcomp - - |xkbprint -label symbols - pc105-uk.ps
% setxkbmap de -option -geometry 'pc(pc102)' -print |xkbcomp - - |xkbprint -label symbols - pc102-de.ps
The answer is from https://unix.stackexchange.com/a/671005