-
-
Save leafhy/2f6bdadfdf18b45ffadbb6036caf1086 to your computer and use it in GitHub Desktop.
Herbstluftwm workspaces for polybar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[module/herbstluftwm] | |
type = custom/script | |
exec-if = ps -C herbstluftwm >/dev/null 2>&1 | |
exec = MONITOR=HDMI-0 ~/.config/polybar/herbstluftwm.sh | |
tail = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
hash herbstclient xrandr | |
print_tags() { | |
for tag in $(herbstclient tag_status "$1"); do | |
name=${tag#?} | |
state=${tag%$name} | |
case "$state" in | |
'#') | |
printf '%%{R} %s %%{R}' "$name" | |
;; | |
'+') | |
printf '%%{F#cccccc}%%{R} %s %%{R}%%{F-}' "$name" | |
;; | |
'!') | |
printf '%%{R} %s! %%{R}' "$name" | |
;; | |
'.') | |
printf '%%{F#cccccc} %s %%{F-}' "$name" | |
;; | |
*) | |
printf ' %s ' "$name" | |
esac | |
done | |
printf '\n' | |
} | |
geom_regex='[[:digit:]]\+x[[:digit:]]\++[[:digit:]]\++[[:digit:]]\+' | |
geom=$(xrandr --query | grep "^$MONITOR" | grep -o "$geom_regex") | |
monitor=$(herbstclient list_monitors | grep "$geom" | cut -d: -f1) | |
print_tags "$monitor" | |
IFS="$(printf '\t')" herbstclient --idle | while read -r hook args; do | |
case "$hook" in | |
tag*) | |
print_tags "$monitor" | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment