diff options
author | InigoGutierrez <inigogf.95@gmail.com> | 2021-11-03 21:08:16 +0100 |
---|---|---|
committer | InigoGutierrez <inigogf.95@gmail.com> | 2021-11-03 21:08:16 +0100 |
commit | a6417aab90f9b4403fb445cd17f5f83758775727 (patch) | |
tree | 4612241d45d49f43a72b5a19c4984b4057ac97a4 | |
parent | bbadea145d57d3c9cad8ac1d51683951838c94c9 (diff) | |
download | scripts-a6417aab90f9b4403fb445cd17f5f83758775727.tar.gz scripts-a6417aab90f9b4403fb445cd17f5f83758775727.zip |
toggleKBLayouts.sh: Script to toggle between a hardcoded list of keyboard layouts.
-rwxr-xr-x | toggleKBLayouts.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/toggleKBLayouts.sh b/toggleKBLayouts.sh new file mode 100755 index 0000000..bd34012 --- /dev/null +++ b/toggleKBLayouts.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +# Toggle between keyboard layouts. + +read -d '' layouts << EOF +es +dvorak es +EOF + +tempFile="/tmp/keyboardLayout" + +[ -f "$tempFile" ] && currentLayout="$(cat "$tempFile")" +if [ -n "$currentLayout" ]; then + line="$(echo "$layouts" | grep -xn "$currentLayout" | cut -d':' -f1)" + [ "$line" -eq "$(echo "$layouts" | wc -l)" ] && line=1 || line=$((line + 1)) +else + line=1 +fi + +selectedLayout="$(echo "$layouts" | sed -n "${line}p")" +echo "$selectedLayout" > "$tempFile" + +setxkbmap $selectedLayout -option caps:swapescape +dunstify -r "$(dunstifyIDs.sh toggleKBLayouts)" -t 500 "$selectedLayout" + +if pgrep -x sxhkd; then + if pgrep -x bspwm; then + pkill sxhkd && sxhkd "$XDG_CONFIG_HOME/sxhkd/sxhkdrcbspc" >~/logs/sxhkd.log & + else + pkill sxhkd && sxhkd >~/logs/sxhkd.log & + fi +fi + |