Last active
April 20, 2020 00:23
-
-
Save ondt/54c3455975f1335b4298cfb591ed3cdf to your computer and use it in GitHub Desktop.
A script that switches keyboard layouts automatically based on the X window title
This file contains hidden or 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