summaryrefslogtreecommitdiff
path: root/bin/extra/cycleKB
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-12-18 13:28:28 +0100
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-12-18 13:28:28 +0100
commit6156f88867f5e4d13227de65f2aa930e81b76fea (patch)
tree4a1e66aca45b7baf95104c6b61a93bcc4526e19e /bin/extra/cycleKB
parent0a69f01a5f7f67bd771fd983aa8ba4146cbafcc8 (diff)
checkpoint
Diffstat (limited to 'bin/extra/cycleKB')
-rwxr-xr-xbin/extra/cycleKB25
1 files changed, 20 insertions, 5 deletions
diff --git a/bin/extra/cycleKB b/bin/extra/cycleKB
index 154f5a1..25f018d 100755
--- a/bin/extra/cycleKB
+++ b/bin/extra/cycleKB
@@ -1,6 +1,21 @@
#!/usr/bin/sh
-keyboards="$HOME/bin/keyboards.txt"
-kb="$(head -n 1 "$keyboards")"
-setxkbmap $kb &
-sed -i '1h;1d;$G' "$keyboards"
-notify-send -t 1000 "cycleKB" "${kb%% *}"
+
+list_layouts()
+{
+cat <<EOF
+us
+colemak -option ctrl:swapcaps,altwin:menu_win
+EOF
+}
+
+current_keymap()
+{
+ setxkbmap -print | awk -F '+' '/xkb_symbols/ {print $2}'
+}
+
+NumLayouts="$(list_layouts | wc -l)"
+IndexLayout="$(list_layouts | awk "/^$(current_keymap)/ {print NR}")"
+[ "$IndexLayout" -eq "$NumLayouts" ] && IndexLayout=1 || IndexLayout=$((IndexLayout + 1))
+Layout="$(list_layouts | sed -n "${IndexLayout}p" )"
+setxkbmap $Layout &
+notify-send -t 1000 "cycleKB" "${Layout%% *}"