#!/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