Last active
August 8, 2023 18:18
-
-
Save olmokramer/b28ff8ed5fd366e3ebb23b79915ec850 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 |
This worked for me "%{A1:herbstclient use $name:}$name %{A}"
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, yes it is possible to make them clickable. See the Polybar wiki's section on formatting on how to do so. Basically just wrap each tag name in
${A1:herbstclient use $name:}
.