dotfiles/.local/bin/scripts/update-keyboard-layout

22 lines
813 B
Plaintext
Raw Normal View History

#!/bin/sh -e
2021-05-02 17:35:50 +00:00
umask 0
2021-03-12 09:21:23 +00:00
{
case $ACTION in
2021-04-21 17:51:56 +00:00
(add) id=1;;
(remove) id=0;;
(*) id=$(! test -c /dev/ttyACM0 -o -c /dev/model01; echo $?);;
2021-03-12 09:21:23 +00:00
esac
echo "Keyboard layout update to $id($ACTION) at $(/usr/bin/date)"
export XAUTHORITY="/run/user/1000/Xauthority" DISPLAY=:0
2021-04-21 17:51:56 +00:00
2021-03-23 20:55:02 +00:00
xkbstate="$(dirname $(dirname $0))/xkblayout-state"
2021-03-25 09:27:44 +00:00
test "$($xkbstate print %C)" -gt 1 && $xkbstate set $id
# Swap semicolon and colon
# https://unix.stackexchange.com/questions/615799/swap-semicolon-colon-to-p-unexpected-cause-semicolon-colon-affected-by-cpas-lock
# test "$id" = "eu" && xmodmap -e 'keysym semicolon = colon semicolon colon semicolon'
2021-12-02 09:35:37 +00:00
if test "$id" = "1"
then setxkbmap eu -option "" && xmodmap -e 'keysym semicolon = colon semicolon colon semicolon'
2021-12-02 09:35:37 +00:00
else setxkbmap de nodeadkeys caps:swapescape
fi
2021-03-12 09:21:23 +00:00
} 2>&1 | tee -a /tmp/scripts.log