#!/bin/sh set -e export NOTIFY_LONG=keyboard export NOTIFY_SHORT=${0##*/} readonly KEYBOARD=at-translated-set-2-keyboard s="$( { hyprctl -j getoption input:kb_layout hyprctl -j getoption input:kb_variant } | jq -rn ' [inputs] | map(.str | split(",\\s*"; "g")) | transpose | map("\(.[0]) (\(.[1]))") | .[] ' | sed -E 's/[a-zA-Z]+/\u&/g' )" choice="$(echo "$s" | osel)" n="$(echo "$s" | sed -n "/$choice/=" | { xargs expr -1 + || true; })" hyprctl switchxkblayout $KEYBOARD $n >/dev/null notify 'Keyboard Layout Changed' "The keyboard layout was changed to ‘$choice’"