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