From 3ed52a75442a01cfa2bf40420469ce86dadfc329 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 18 Nov 2023 18:48:49 +0100 Subject: fuzzel: Switch from wofi to fuzzel --- .local/bin/chkb | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to '.local/bin/chkb') diff --git a/.local/bin/chkb b/.local/bin/chkb index 1dcf729..7bfefcc 100755 --- a/.local/bin/chkb +++ b/.local/bin/chkb @@ -2,20 +2,26 @@ set -e -OSEL_GUI_FLAGS='-r "echo \"%s\" | cut -f2 | xargs echo -n"' -export OSEL_GUI_FLAGS="$OSEL_GUI_FLAGS -Oalphabetical" -export OSEL_TERM_FLAGS='--with-nth=2..' readonly KEYBOARD=at-translated-set-2-keyboard -if choice="` - sed -En 's/\s*name\[Group1\]\s*=\s*"([^"]*)"\s*;\s*/\1/p' \ - ~/.xkb/symbols/mango \ - | sort \ - | nl -v0 -nln \ - | osel -`" +s="$( + { + hyprctl -j getoption input:kb_layout + hyprctl -j getoption input:kb_variant + } | jq ' + .str | split(",\\s*"; "g") + ' | jq -rn ' + [inputs] + | transpose + | map("\(.[0]) (\(.[1]))") + | .[] + ' | sed -E 's/[a-zA-Z]+/\u&/g' +)" + +if choice="$(echo "$s" | osel)" then - hyprctl switchxkblayout $KEYBOARD ${choice% *} >/dev/null + n="$(echo "$s" | sed -n "/$choice/=" | xargs expr -1 +)" + hyprctl switchxkblayout $KEYBOARD $n >/dev/null notify "${0##*/}" keyboard 'Keyboard Layout Changed' \ - "The keyboard layout was changed to ‘${choice##* }’" + "The keyboard layout was changed to ‘$choice’" fi -- cgit v1.2.3