Last active
February 8, 2025 15:40
-
-
Save nat-418/135a62fb9f37cc87cd70af1ab72e276a to your computer and use it in GitHub Desktop.
How to enable the Hyper key on Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Desktop Entry] | |
Name[en_US]=hyper-key | |
Comment[en_US]=Set CapsLock to Control and Escape to Hyper | |
Exec=/usr/local/bin/hyper-key.sh | |
Icon=application-default-icon | |
X-GNOME-Autostart-enabled=true | |
Type=Application |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# This file contains commands designed to modify an ANSI keyboard | |
# layout to be more ergonomic and allow a greater range of user-defined | |
# keybindings by levraging the archaic Hyper key orginally found on | |
# Symbolics "Space Cadet" keyboards and functionally vestigial in Linux. | |
# The script can be run standalone to test or set to automatically on | |
# user login, eg. in $HOME/.config/autostart/hyper-key.desktop | |
# Start with a clean ANSI US QWERTY layout. This can also be used to | |
# unset the rest of the configuration commands. | |
pkill xcape | |
setxkbmap -layout us | |
# Abolish CapsLock and replace with Control | |
setxkbmap -option ctrl:nocaps | |
# Some Linux distributions like Ubuntu have Hyper set to the same mappings | |
# as Super (Mod4), so we need to unset those | |
xmodmap -e "remove Mod4 = Hyper_L" | |
# Set Escape to be the left Hyper key | |
xmodmap -e "keycode 9 = Hyper_L" | |
# Set Hyper_L to use the normally unused Mod3 | |
xmodmap -e "add Mod3 = Hyper_L" | |
# Set left Control to Escape | |
xmodmap -e "keycode 37 = Escape" | |
# Old Escape / new Hyper_L sends Escape when pressed alone | |
xcape -e '#9=Escape' | |
# Old CapsLock / new Control_L sends Escape when pressed alone | |
xcape -e '#66=Escape' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an attempt at a more ergonomic programmer's keyboard layout without the need of special hardware (thumb clusters, etc.). With this setup, a user essentially has the entire home row area of the keyboard available for custom hotkeys using something like AutoKey. The default ANSI placement of the left Control key is in my opinion difficult to reach, while hitting the CapsLock or Escape key is easier. By using Hyper instead of Control or Alt for user-defined custom keybindings, there is no risk of accidentally clobbering some existing program's settings. Hyper allows an easy logical separation of concerns for modifier keys: Alt is for application shortcuts, Control is for terminal controls, and Hyper is for user customization.