herbstpanel: only show urgent tags

While there, do some housekeeping in shell style.
This commit is contained in:
Lucas 2020-01-26 17:28:08 +00:00
parent dda3865373
commit 64ef0b5728

View File

@ -14,42 +14,29 @@ if [ -f ~/.config/herbstluftwm/theme ]; then
. ~/.config/herbstluftwm/theme . ~/.config/herbstluftwm/theme
fi fi
tagstatus() { show_urgent_tags() {
mon=$1 mon=$1
herbstclient tag_status "$mon" | tr "\t" "\n" | { herbstclient tag_status "$mon" | tr "\t" "\n" | {
out= s=
while IFS= read -r line; do while IFS= read -r line; do
[ -z "$line" ] && continue [ -n "$line" ] || continue
tag=${line#[.:+#%!-]} tag=${line#[.:+#%!-]}
rev=
color=$hlwm_color8
case $line in case $line in
:*) color=$hlwm_foreground !*) focused=$(herbstclient attr tags.focus.name)
;; [ "$tag" != "$focused" ] && s=$s"$line "
[#-]*) color=$hlwm_color14
;;
[%+]*) color=$hlwm_color6
;;
!*) color=$hlwm_color13
focused=$(herbstclient attr tags.focus.name)
if [ "$tag" = "$focused" ]; then
color=$hlwm_color14
fi
;; ;;
esac esac
o=$o"%{O1}%{U$color+u}%{O5}%{U--u}"
done done
printf "%%{c}%s%%{O1}\n" "$o" printf "%%{l}%%{F%s}%s%%{F-}\n" "$hlwm_color9" "$s"
} }
} }
taglist() { tagstatus() {
mon=$1 mon=$1
tagstatus "$mon" show_urgent_tags "$mon"
herbstclient -i "tag_changed|tag_flags" \ herbstclient -i "tag_flags" | while read -r discard; do
| while read -r discard; do show_urgent_tags "$mon"
tagstatus "$mon"
done done
} }
@ -63,10 +50,13 @@ while IFS=" " read -r m x y w h; do
center= center=
right= right=
{ {
taglist "$m" & tagstatus "$m" &
spoon -t & spoon -t &
} | while IFS= read line; do } | while IFS= read line; do
case $line in case $line in
"%{l}"*)
left=$line
;;
"%{c}"*) "%{c}"*)
center=$line center=$line
;; ;;
@ -75,9 +65,8 @@ while IFS=" " read -r m x y w h; do
;; ;;
esac esac
printf "%s%s%s\n" "$left" "$center" "$right" printf "%s%s%s\n" "$left" "$center" "$right"
done | lemonbar-xft -g "$w"x"$h"+"$x"+"$y" \ done | lemonbar-xft -g "${w}x${h}+${x}+${y}" \
-B "$hlwm_background" -F "$hlwm_foreground" \ -B "$hlwm_background" -F "$hlwm_foreground" -f "$hlwm_face" &
-f "$hlwm_face" | sh &
done done
herbstclient -w reload >/dev/null herbstclient -w reload >/dev/null
kill 0 kill 0