Created
July 19, 2014 23:38
-
-
Save bjonord/3f8850cad11d992b4bc2 to your computer and use it in GitHub Desktop.
keyboard-switcher
This file contains 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/zsh | |
# If an explicit layout is provided as an argument, use it. Otherwise, select the next layout from | |
# the set [us(colemak), us(altgr-intl), se]. | |
if [[ -n "$1" ]]; then | |
setxkbmap $1 -variant $2 | |
else | |
layout=$(setxkbmap -query | awk '$1 ~/layout/ {print $2}') | |
variant=$(setxkbmap -query | awk '$1 ~/variant/ {print $2}') | |
case $layout$variant in | |
uscolemak) | |
setxkbmap se -option caps:ctrl_modifier | |
;; | |
se) | |
setxkbmap us -variant altgr-intl -option caps:ctrl_modifier | |
;; | |
*) | |
setxkbmap us -variant colemak -option caps:ctrl_modifier | |
;; | |
esac | |
fi | |
result=$(setxkbmap -query | awk '$1 ~/(layout|variant)/ {print $2}') | |
echo $result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment