summaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/chkb29
-rwxr-xr-x.local/sbin/chkb14
2 files changed, 14 insertions, 29 deletions
diff --git a/.local/bin/chkb b/.local/bin/chkb
deleted file mode 100755
index 6abe5ae..0000000
--- a/.local/bin/chkb
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/local/bin/andy
-
-set -e NOTIFY_LONG keyboard
-set -e NOTIFY_SHORT `basename $args[0]
-
-set KEYBOARD at-translated-set-2-keyboard
-
-set 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
- s/Us \(Basic\)/English (US)/
- '
-}
-
-set choice `echo $s | osel
-set n `echo $s | sed -n "/$choice/=" | { xargs expr -1 + || true }
-hyprctl switchxkblayout $KEYBOARD $n >_
-notify 'Keyboard Layout Changed' "The keyboard layout was changed to ‘$choice’"
diff --git a/.local/sbin/chkb b/.local/sbin/chkb
new file mode 100755
index 0000000..36398e3
--- /dev/null
+++ b/.local/sbin/chkb
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+export NOTIFY_LONG=keyboard
+export NOTIFY_SHORT="$(basename "$0")"
+
+readonly LAYOUTS="$(niri msg -j keyboard-layouts)"
+sel="$(echo "$LAYOUTS" | jq -r '.names.[]' | osel -i)"
+if [ -n "$sel" ]
+then
+ niri msg action switch-layout "$sel"
+ choice="$(echo "$LAYOUTS" | jq -r ".names.[$sel]")"
+ notify 'Keyboard Layout Changed' \
+ "The keyboard layout was changed to ‘$choice’"
+fi