diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-02-03 18:31:23 +0100 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-02-03 18:31:23 +0100 |
commit | 4e4ae20a52db369f436c8ec82c1004130ed88540 (patch) | |
tree | 1bbd1aead44a5fd7002cdca47bc0aa5bd846c9a4 /bin | |
parent | 07ad983aebf388065be7d650b7e08204100d1ed4 (diff) |
Refactor cycling logic
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/extra/cycleKB | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/bin/extra/cycleKB b/bin/extra/cycleKB index e2cb19d..70b01df 100755 --- a/bin/extra/cycleKB +++ b/bin/extra/cycleKB @@ -1,11 +1,6 @@ -#!/usr/bin/env sh -keyboards_file="/home/aluc/bin/keyboards.txt" -cur_keyboard="$(setxkbmap -print | grep "xkb_symbols" | cut -f 2 -d "+")" -# Get line number of match -line="$(awk "/${cur_keyboard}/ {print NR}" "${keyboards_file}")" -lines="$(wc -l "${keyboards_file}" | cut -f 1 -d ' ')" -# cycle back to first line -[[ "$line" == "$lines" ]] && line=1 || ((line++)) -new_keyboard="$(sed -n "${line}p" "${keyboards_file}")" -setxkbmap "${new_keyboard}" -dunstify "cycleKB" "keyboard: <b>${new_keyboard}</b>" +#!/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" "keyboard: <b>$kb</b>" |