Last active
August 29, 2015 14:00
-
-
Save nlamprian/dd583c858e1920d960cd to your computer and use it in GitHub Desktop.
Swaps "Caps Lock" and "Left Ctrl" in Ubuntu
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 | |
# Script to remap the "Caps Lock" and "Left Ctrl" keys | |
# The change persists between sessions | |
# | |
# Caps Lock -> Left Ctrl | |
# Left Ctrl -> Caps Lock | |
# | |
# Make it executable and run it: | |
# chmod +x capslock_lctrl_remap.sh | |
# ./capslock_lctrl_remap.sh | |
if [ $# = 1 ] && [ "$1" = "-h" ]; then | |
echo "Arguments:" | |
echo "-h\thelp" | |
echo "-l\tlogout" | |
exit 0 | |
fi | |
# Remapping | |
cd /usr/share/X11/xkb/symbols/ | |
sudo sed -i -e "/key <CAPS>/ s/Caps_Lock/Control_L/g" -e "/key <LCTL>/ s/Control_L/Caps_Lock/g" pc | |
# Enforces keyboard layouts recompilation | |
cd /var/lib/xkb/ | |
sudo rm * | |
# Logout: Save any open files | |
if [ "$1" = "-l" ]; then | |
echo "Logging out" | |
kill -9 -1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment