commit de82eba1b397fc48b4fba516c9e1a39e7dd8ba1a parent 9fc70e189de45c6b12736e431ef3f4f706baa627 Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Wed, 6 Jan 2021 19:17:06 +0100 clean up script to toggle between keyboard layouts Diffstat:
M | .local/bin/keyboard-layout-switch.sh | | | 16 | +++++----------- |
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/.local/bin/keyboard-layout-switch.sh b/.local/bin/keyboard-layout-switch.sh @@ -1,5 +1,5 @@ #!/bin/sh -set -e +# toggle between two keyboard layouts layoutfile="$HOME/.cache/kbd-layout" @@ -8,23 +8,17 @@ lang1="us" lang2="dk" set_language() { - echo "$1" > "$layoutfile" - #pkill -RTMIN+3 i3blocks - setxkbmap "$1" -option -option ctrl:nocaps #-option altwin:swap_lalt_lwin - #xmodmap $HOME/.Xmodmap - #notify "$1" + printf '%s\n' "$1" > "$layoutfile" + setxkbmap "$1" -option -option ctrl:nocaps } -[ $# -gt 0 ] && set_language "$1" && exit - -# write the file if it doesn't exist if [ ! -f "$layoutfile" ]; then - set_language "us" + set_language "$lang1" exit 0 fi # read the language file, and switch to the other language -currlang=$(cat "$layoutfile") +currlang="$(cat "$layoutfile")" if [ "$currlang" = "$lang1" ]; then set_language "$lang2"