Skip to content

Instantly share code, notes, and snippets.

@leafhy
Forked from olmokramer/config
Created September 22, 2020 17:42
Show Gist options
  • Save leafhy/2f6bdadfdf18b45ffadbb6036caf1086 to your computer and use it in GitHub Desktop.
Save leafhy/2f6bdadfdf18b45ffadbb6036caf1086 to your computer and use it in GitHub Desktop.
Herbstluftwm workspaces for polybar
[module/herbstluftwm]
type = custom/script
exec-if = ps -C herbstluftwm >/dev/null 2>&1
exec = MONITOR=HDMI-0 ~/.config/polybar/herbstluftwm.sh
tail = true
#!/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