Skip to content

Instantly share code, notes, and snippets.

@deseven
Created July 22, 2016 10:34
Show Gist options
  • Save deseven/3549b4f86fb783b1cd86a46676f9fe18 to your computer and use it in GitHub Desktop.
Save deseven/3549b4f86fb783b1cd86a46676f9fe18 to your computer and use it in GitHub Desktop.
Simple script to change keyboard layout with indication
# capsSwitch
# depends on keyboardSwitcher and maclight
# to get the list of possible layouts, check `keyboardSwitcher list` output
# to check what layouts you use, check `keyboardSwitcher get` while switching layouts
layout1="U.S."
layout2="Russian - PC"
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
# comment this if your gem uses default system paths
export RBENV_ROOT="/usr/local/opt/rbenv"
export GEM_HOME="/usr/local/opt/gems"
export GEM_PATH="/usr/local/opt/gems"
# uncomment this if you need to write log
#exec 3>&1 4>&2
#trap 'exec 2>&4 1>&3' 0 1 2 3
#exec 1>$HOME/capsSwitch.log 2>&1
currentLayout=`keyboardSwitcher get 2>&1`
if [ "$currentLayout" = "$layout1" ]; then
keyboardSwitcher "select" "$layout2" && maclight keyboard set -a 1
else
keyboardSwitcher "select" "$layout1" && maclight keyboard set -a 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment