#!/bin/sh set -e readonly KEYBOARD=at-translated-set-2-keyboard 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 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’" fi