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

18 lines
745 B
Bash
Executable File

#!/bin/sh
umask 0
{
case $ACTION in
(add) id=1;;
(remove) id=0;;
(*) id=$(! test -c /dev/ttyACM0; echo $?);;
esac
echo "Keyboard layout update to $id($ACTION) at $(date)"
export XAUTHORITY="/run/user/1000/Xauthority" DISPLAY=:0
xkbstate="$(dirname $(dirname $0))/xkblayout-state"
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'
test "$id" = "1" && setxkbmap eu && xmodmap -e 'keysym semicolon = colon semicolon colon semicolon' || setxkbmap de nodeadkeys
} 2>&1 | tee -a /tmp/scripts.log