Skip to content

Instantly share code, notes, and snippets.

@w-shackleton
Created June 21, 2016 00:10
Show Gist options
  • Save w-shackleton/75f1cbf0134008695921e2ca0ccfc216 to your computer and use it in GitHub Desktop.
Save w-shackleton/75f1cbf0134008695921e2ca0ccfc216 to your computer and use it in GitHub Desktop.
Scripts to enable and disable swapping caps lock and escape on Linux, and to disable during a program's execution.
#!/bin/bash
if [[ $# == 0 ]]
then
echo "Usage: $0 [normal|swapped]"
fi
case "$1" in
normal) gsettings set org.gnome.desktop.input-sources xkb-options "[]" ;;
swapped) gsettings set org.gnome.desktop.input-sources xkb-options "['caps:swapescape']" ;;
*)
echo "Invalid argument"
exit 1
esac
#!/bin/bash
# Use this script as:
# ./wrap.sh <command> <arg1...>
# To swap caps lock and escape back during the execution of the given command.
# This is useful when eg. running a game in Steam; set the launch options as
# /path/to/.../wrap.sh %command%
# to disable swapping during the game.
gsettings set org.gnome.desktop.input-sources xkb-options "[]"
$@
gsettings set org.gnome.desktop.input-sources xkb-options "['caps:swapescape']"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment