Skip to content

Instantly share code, notes, and snippets.

@ryankhart
Last active December 20, 2018 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryankhart/456a70cb53f918eafb7cd99492d8dbcf to your computer and use it in GitHub Desktop.
Save ryankhart/456a70cb53f918eafb7cd99492d8dbcf to your computer and use it in GitHub Desktop.
Swap both left and right Control and Alt keys on Linux
#!/bin/bash
# Create or append to .Xmodmap the new
# mappings for Control and Alt
echo '
clear control
clear mod1
keycode 105 = Alt_R
keycode 108 = Control_R
keycode 37 = Alt_L Meta_L
keycode 64 = Control_L
add Control = Control_L Control_R
add Mod1 = Alt_L Meta_L' >> ~/.Xmodmap
# Activate the changes now
xmodmap ~/.Xmodmap
# Set it to keep the changes at startup
echo '
# On startup, swap Alt and Control
if [ -f $HOME/.Xmodmap ]; then
/usr/bin/xmodmap $HOME/.Xmodmap
fi' >> ~/.profile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment