From 5fb19f10389b70ee2389755106092a9ef6c64598 Mon Sep 17 00:00:00 2001 From: David Moc Date: Sun, 24 May 2026 11:48:07 +0200 Subject: Go --- polybar/scripts/kb-switch.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 polybar/scripts/kb-switch.sh (limited to 'polybar/scripts/kb-switch.sh') 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 -- cgit v1.2.3