From 4817c1bc0222f7172d1acb9c18912a7e6f36a3c7 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 25 Aug 2023 01:09:10 +0300 Subject: bin/sbin: Refactor shell scripts --- .local/bin/chkb | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to '.local/bin/chkb') diff --git a/.local/bin/chkb b/.local/bin/chkb index bc6da23..4f96877 100755 --- a/.local/bin/chkb +++ b/.local/bin/chkb @@ -2,18 +2,19 @@ set -e -export OSEL_GUI='wofi -d -r "echo \"%s\" | cut -f2 | xargs echo -n"' +export OSEL_GUI_FLAGS='-r "echo \"%s\" | cut -f2 | xargs echo -n"' -choice="`sed -En 's/\s*name\[Group1\]\s*=\s*"([^"]*)"\s*;\s*/\1/p' \ - ~/.xkb/symbols/mango \ - | sort \ - | nl -v0 -nln \ - | osel`" - -[ -n "$choice" ] && { +if choice="` + sed -En 's/\s*name\[Group1\]\s*=\s*"([^"]*)"\s*;\s*/\1/p' \ + ~/.xkb/symbols/mango \ + | sort \ + | nl -v0 -nln \ + | osel +`" +then hyprctl -j devices \ | jq -r '.keyboards[-1].name' \ - | xargs -I{} hyprctl switchxkblayout {} ${choice% *} + | xargs -I{} hyprctl switchxkblayout {} ${choice% *} >/dev/null notify-send -a "${0##*/}" -u normal 'Keyboard Layout Changed' \ - "The keyboard layout was changed to ‘${choice##* }’" -} + "The keyboard layout was changed to ‘${choice##* }’." +fi -- cgit v1.2.3