aboutsummaryrefslogtreecommitdiffstats
path: root/bin/cwmbar
diff options
context:
space:
mode:
authorEugene Triguba <hello@eugenetriguba.com>2026-10-17 10:40:11 -0700
committerEugene Triguba <hello@eugenetriguba.com>2026-10-17 10:40:11 -0700
commitea127689e0ae2d39b49004be605e541ff80e2621 (patch)
treeabbe79e5e37792bd8ebea8f9ac788ff5b8aed704 /bin/cwmbar
downloadopenbsd-dotfiles-ea127689e0ae2d39b49004be605e541ff80e2621.zip
Initial Commit
Diffstat (limited to 'bin/cwmbar')
-rwxr-xr-xbin/cwmbar37
1 files changed, 37 insertions, 0 deletions
diff --git a/bin/cwmbar b/bin/cwmbar
new file mode 100755
index 0000000..7d723dd
--- /dev/null
+++ b/bin/cwmbar
@@ -0,0 +1,37 @@
+#!/bin/sh
+set -o errexit
+
+main() {
+ # Redraw when the active group or the window list changes.
+ # -spy prints once at startup too, so the bar draws immediately.
+ xprop -root -spy _NET_CURRENT_DESKTOP _NET_CLIENT_LIST |
+ while read -r _; do
+ groups
+ done | lemonbar-xft -g x18 -B '#222222' -F '#dddddd' | sh
+}
+
+groups() {
+ cur=$(xprop -root _NET_CURRENT_DESKTOP | awk '{print $3}')
+ num=$(xprop -root _NET_NUMBER_OF_DESKTOPS | awk '{print $3}')
+
+ # groups that currently contain windows
+ occ=$(for w in $(xprop -root _NET_CLIENT_LIST | cut -d'#' -f2 | tr -d ','); do
+ xprop -id "$w" _NET_WM_DESKTOP 2>/dev/null | awk '{print $3}'
+ done | sort -u)
+
+ out=""
+ i=1 # skip 0 ("nogroup")
+ while [ "$i" -lt "$num" ]; do
+ if [ "$i" -eq "$cur" ]; then
+ out="$out%{R} $i %{R}" # active: reversed colors
+ elif echo "$occ" | grep -qx "$i"; then
+ out="$out%{A:xdotool set_desktop $i:} $i %{A}" # occupied, clickable
+ else
+ out="$out%{F#555}%{A:xdotool set_desktop $i:} $i %{A}%{F-}" # empty, dimmed
+ fi
+ i=$((i + 1))
+ done
+ echo "%{l}$out"
+}
+
+main