diff options
| author | David Moc <personal@cdatgoose.org> | 2026-05-24 11:48:07 +0200 |
|---|---|---|
| committer | David Moc <personal@cdatgoose.org> | 2026-05-24 11:48:07 +0200 |
| commit | 5fb19f10389b70ee2389755106092a9ef6c64598 (patch) | |
| tree | 969eb0466de581cb14aa09f751a95138620fc720 /polybar/scripts/kb-switch.sh | |
Go
Diffstat (limited to 'polybar/scripts/kb-switch.sh')
| -rwxr-xr-x | polybar/scripts/kb-switch.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/polybar/scripts/kb-switch.sh b/polybar/scripts/kb-switch.sh new file mode 100755 index 0000000..af231f0 --- /dev/null +++ b/polybar/scripts/kb-switch.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +set -euo pipefail + +DMENU="${DMENU:-/usr/bin/dmenu}" +SETXKBMAP="${SETXKBMAP:-/usr/bin/setxkbmap}" +LOG_FILE="${XDG_RUNTIME_DIR:-/tmp}/polybar-kb-switch.log" + +exec 2>>"$LOG_FILE" + +export DISPLAY="${DISPLAY:-:0}" +if [ -z "${XAUTHORITY:-}" ] && [ -r "$HOME/.Xauthority" ]; then + export XAUTHORITY="$HOME/.Xauthority" +fi + +choice="$( + printf '%s\n' "us" "us dvorak" "cz" | + "$DMENU" -i -p "Keyboard" \ + -b \ + -fn "FiraCode Nerd Font-12" \ + -nb "#282828" \ + -nf "#ebdbb2" \ + -sb "#d79921" \ + -sf "#282828" +)" || exit 0 + +case "$choice" in + "us") + "$SETXKBMAP" us + ;; + "us dvorak") + "$SETXKBMAP" us -variant dvorak + ;; + "cz") + "$SETXKBMAP" cz + ;; +esac |
