A script that switches keyboard layouts automatically based on the X window title
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/bash | |
# for xtitle to work properly | |
sleep 0.5 | |
layout="us" | |
xtitle -s -f '%s\n' | while read window_title; do | |
case $window_title in | |
"Messenger"* | "Slack"*) | |
if [[ "$layout" != "cz" ]]; then | |
echo "Changing keyboard layout to CZ" | |
setxkbmap cz -variant qwerty | |
layout="cz" | |
fi | |
;; | |
*) | |
if [[ "$layout" != "us" ]]; then | |
echo "Changing keyboard layout to US" | |
setxkbmap us | |
layout="us" | |
fi | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dependency: https://github.com/baskerville/xtitle