Skip to content

Instantly share code, notes, and snippets.

@rbreaves
Last active March 31, 2024 10:35
Show Gist options
  • Save rbreaves/f4cf8a991eaeea893999964f5e83eebb to your computer and use it in GitHub Desktop.
Save rbreaves/f4cf8a991eaeea893999964f5e83eebb to your computer and use it in GitHub Desktop.
Universal macOS keyboard layout for Linux - Applies to All Windows and Apple Keyboards
# permanent apple keyboard keyswap
echo "options hid_apple swap_opt_cmd=1" | sudo tee -a /etc/modprobe.d/hid_apple.conf
update-initramfs -u -k all
# Temporary & instant apple keyboard keyswap
echo '1' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd
# Windows and Mac keyboards - GUI (Physical Alt is Ctrl, Physical Super is Alt, Physical Ctrl is Super)
setxkbmap -option;setxkbmap -option altwin:ctrl_alt_win
# Windows and Mac keyboards - Terminal Apps (Physical Alt is Super, Physical Super is Alt, Physical Ctrl is Ctrl)
setxkbmap -option;setxkbmap -option altwin:swap_alt_win
# If the hid_apple driver is not loaded for Apple keyboards, which can be found out
# by the lsmod command then the above setxkbmap commands will not work
# Use the following commands for Apple style keyboards without an hid_apple driver
#
# Note: this could also apply to hid_apple driver as well
# if this option is set to 0 inside swap_opt_cmd
#
lsmod | grep hid_apple
# Apple keyboard without hid_apple - GUI
setxkbmap -option;setxkbmap -option ctrl:swap_lwin_lctl,ctrl:swap_rwin_rctl
# Apple keyboard without hid_apple - Terminal
setxkbmap -option;setxkbmap -option altwin:alt_super_win
#
# If you want a systemd service and bash script to help toggle between
# GUI and Terminal applications then look at project Kinto.
# https://github.com/rbreaves/kinto
#
# Note: The above may not work for Chromebooks running Linux, please look
# at project Kinto for that.
#
# If anyone would like to contribute to the project then please do!
#
@rbreaves
Copy link
Author

This gist was an early document & outline for what needed to happen for Kinto to be created to fully mimic Mac style keys. It is not intended to be a full solution for anything or anyone. Anyone can use it & look at it of course & it may be helpful to some.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment