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
1 changed files with 16 additions and 27 deletions

View File

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