Skip to content

Instantly share code, notes, and snippets.

@crawsible
Last active March 26, 2016 21: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 crawsible/13b7b4d152ce0b5f8983 to your computer and use it in GitHub Desktop.
Save crawsible/13b7b4d152ce0b5f8983 to your computer and use it in GitHub Desktop.
A script for toggling the alt/win keyboard swap in GNOME settings.
#!/usr/bin/env bash
OLD_KBOPTS=`gsettings get org.gnome.libgnomekbd.keyboard options`
TOGGLE_OP="altwin\taltwin:swap_alt_win"
if [[ $OLD_KBOPTS == *"$TOGGLE_OP"* ]]
then
OP="-"
echo "Unswapping alt and win..."
else
OP="+"
echo "Swapping alt and win..."
fi
NEW_KBOPTS=`echo $OLD_KBOPTS | sed "s/'/\"/g" | jq ". |= .$OP[\"$TOGGLE_OP\"]" | sed "s/\"/'/g"`
gsettings set org.gnome.libgnomekbd.keyboard options "$NEW_KBOPTS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment