1

I am trying to use shortcuts in Gnome that involve the hyper-key. I can successfully add them as shown in the picture here: enter image description here

My hyper key is remapped from caps lock via setxkbmap -option "caps:hyper".

Hyper works correctly in, e.g., Emacs. (When I push Caps-Lock-A, Emacs says H-a is undefined.)

But when I press Caps-Lock-A, the shortcut is not executed. (E.g., in the terminal, it simply inserts the letter a.)

How to support hyper in Gnome shortcuts? (Or short cuts involving caps lock in another way but not remapped to super because I want separate super and caps-lock shortcuts.)

Dominique Unruh
  • 1,248
  • 8
  • 23
  • 1
    I have the same problem. Mapped Caps to Hyper in the Tweaks program. xev correctly reports Hyper_L key when I press Caps. But Gnome seems to handle Hyper the same as Super. When I define a shortcut in Gnome Settings and Press Caps+X then Gnome recognizes it as Super+X... Very disappointing. But pressing just Caps doesn't open the Activity menu as the Super key does. So in this regard at least it is handled differently... – kayahr Jun 26 '22 at 09:59

2 Answers2

2

On Wayland, you can achieve this by creating a .config/xkb/symbols/capslock with the following content:

xkb_symbols "hyper" {
    key <CAPS> { [ Hyper_L ] };
    modifier_map Mod3 { <CAPS> };
};
  • The caps:hyper option does exactly this, so this setup is not required, as it's already upstream. But if someone wants to use a different key for Hyper, this snippet is useful for modifying it. The only additional thing to note is that for it to work you'd also need evdev and evdev.xml files to define an option enabling those symbols. Great explanation of what needs to be done is at https://who-t.blogspot.com/2020/09/user-specific-xkb-configuration-putting.html . Note that it also defines a layout, which is not needed in this case. Parts 1-3 linked from that post are also good. – Alesya Huzik Jan 16 '23 at 22:26
1

I found a solution for my own problem with the Hyper key, maybe this solution works for you as well (If you are using Xorg. I guess the solution doesn't work with Wayland...):

First I mapped Caps to Hyper in the tweaks program:

enter image description here

But when I add a shortcut in Gnome Settings then the Shortcut was recognized as Super instead of Hyper. The problem seems to be that Super and Hyper is both mapped to mod4 in xmodmap:

$ xmodmap -pm
xmodmap:  up to 5 keys per modifier, (keycodes in parentheses):

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

This command moves Hyper_L to mod3:

$ xmodmap -e "remove mod4 = Hyper_L" -e "add mod3 = Hyper_L"

Create $HOME/.config/autostart/xmodmap.desktop with the following content to run this xmodmap command on startup:

[Desktop Entry]
Name=Xmodmap
Exec=xmodmap -e "remove mod4 = Hyper_L" -e "add mod3 = Hyper_L"
Terminal=false
Type=Application

Now Hyper is correctly recognized in keyboard shortcut settings and the shortcuts are working fine.

kayahr
  • 20,913
  • 29
  • 99
  • 147
  • I believe I tried the same (including the Xmodmap configuration), except that I configured the caps-lock behavior via the command line `setxkbmap -option "caps:hyper"` which, I thought, would do the same as the GUI option you describe. Either I made a mistake somewhere when testing this, or there is a difference between the GUI option and the command line command. – Dominique Unruh Jun 29 '22 at 12:33