Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emitting Hyper_L #22

Closed
mwgkgk opened this issue Dec 6, 2019 · 8 comments
Closed

Emitting Hyper_L #22

mwgkgk opened this issue Dec 6, 2019 · 8 comments

Comments

@mwgkgk
Copy link

mwgkgk commented Dec 6, 2019

Xmodmap has support for the historic Hyper key (archwiki source):

$ xmodmap -pm

xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Meta_L (0xcd)
mod2        Num_Lock (0x94)
mod3      
mod4        Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  ISO_Level3_Shift (0x6c),  Mode_switch (0x85),  Mode_switch (0xcb)

Which seems to have keycode 0xcf. Sxhkd has support for catching Hyper as one of the modifiers.

However neither keycode nor symbol can be found in linux/input-event-codes.h.

More generally, maybe aliasing a keycode directly could serve as a workaround for similar cases.

@david-janssen
Copy link
Collaborator

Yeah, this is another example of that difference between linux kernel key events and X11 key events. X11 takes the linux-kernel events and maps them onto its own version of key-events, but this is completely out of scope for kmonad since we try to stick as close to kernel as possible (this way it generalizes, for example, to Wayland, or even to Windows (which, admittedly, is a huge headache, but it works :-)).

I'm going to close this issue, since there is nothing I can do about it in kmonad, but it is a good idea to add a bit of documentation about this in the README at some point.

@david-janssen
Copy link
Collaborator

Actually, here's a bit of documentation about how to map linux key events to X11 key events to get a hyper-key to register:

https://wiki.archlinux.org/index.php/Xmodmap#Turn_CapsLock_into_Control,_and_LeftControl_into_Hyper

@divansantana
Copy link

@david-janssen An example or some docs on how to get a key to double as hyper and a standardd key with kmonad would be great. I can't figure it out.

@david-janssen
Copy link
Collaborator

Hey Divan,

So, the issue is that HyperL is not a linux-key at all, it is a special key that gets supported by X11. KMonad doesn't stray at all into X11 territory, this way we can function independently. Therefore, to make HyperL work you will need to do 2 things:

Map a key in KMonad to emit some linux keycode, K
Instruct X11 to tread K like HyperL

The easiest way to do that, I guess, would be to figure out exactly what key you are using right now to trigger HyperL. Let's say you current OS treats right control as HyperL, then simply mapping some key to emit right control should do the trick.

An additional source of confusion is that the keycodes used by xmodmap don't actually line up with the linux event-codes. So if you look at this subset of a .xmodmap configuration I copy-pasted from the above wiki link:

clear      lock 
clear   control
keycode      37 = Hyper_L
keycode      66 = Control_L

Then you can see that they map 37 ('Control_L') to 'Hyper_L', and 66 ('CapsLock') to 'Control_L'.

So basically, to repeat: figure out which intermediate button you want to use, then make sure your kmonad config emits that keycode in the way you want it to (i.e. which layer, tap-hold combo etc.), and also make sure that X11 knows that that key should be 'HyperL'.

Sorry, it's hard to explain this stuff in text without being confusing. Hope I managed to clarify things? I think the idea of writing some documentation explaining this is a good idea, so I am reopening this issue.

@david-janssen david-janssen reopened this Aug 23, 2020
@divansantana
Copy link

@david-janssen Brilliant. Thanks for the detailed quick reply. Let me have a look at it and will revert.

@david-janssen
Copy link
Collaborator

Entered into faq in: fecdb82

Closing.

@mstenek
Copy link

mstenek commented Jun 6, 2023

Yeah, this is another example of that difference between linux kernel key events and X11 key events. X11 takes the linux-kernel events and maps them onto its own version of key-events, but this is completely out of scope for kmonad since we try to stick as close to kernel as possible (this way it generalizes, for example, to Wayland, or even to Windows (which, admittedly, is a huge headache, but it works :-)).

Hmm, it seems that the super key is not listed in input-event-codes.h either (am I missing it?), yet you mention that super can be configured with kmonad. How do you map the super key?

@mstenek
Copy link

mstenek commented Jun 8, 2023

If you use emacs, the manual says that you can enter C-x @ h to add the Hyper flag to the next character (i.e. your mimicking H- hyper key.

So, this setup worked for me:

(defalias hyper #(C-x S-2 h) ;; S-2 produces the '@'

and just assign @hyper to any button you fancy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants