env/xdg-config-dir/herbstluftwm/herbstpanel.sh

85 lines
1.7 KiB
Bash
Raw Normal View History

2019-09-11 04:11:40 +02:00
#!/bin/sh
# env
# Written in 2019-2020,2023 by Lucas
2019-09-11 04:11:40 +02:00
# CC0 1.0 Universal/Public domain - No rights reserved
#
# To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
# public domain worldwide. This software is distributed without any
# warranty. You should have received a copy of the CC0 Public Domain
# Dedication along with this software. If not, see
# <http://creativecommons.org/publicdomain/zero/1.0/>.
if [ -r ~/.config/herbstluftwm/theme ]; then
2019-09-11 04:11:40 +02:00
. ~/.config/herbstluftwm/theme
fi
2020-07-12 17:17:12 +02:00
bar_geometry()
2020-05-31 04:43:23 +02:00
{
herbstclient monitor_rect "$m" | {
read -r mx my mw mh
printf "%ux%u+%u+%u\n" "$mw" "$hlwm_font_height" "$mx" "$my"
}
}
show_tags()
{
2019-09-11 04:11:40 +02:00
mon=$1
herbstclient tag_status "$mon" | tr "\t" "\n" | {
2020-01-31 04:03:27 +01:00
focused=$(herbstclient attr tags.focus.name)
s=
2019-09-11 04:11:40 +02:00
while IFS= read -r line; do
[ -n "$line" ] || continue
2019-09-11 04:11:40 +02:00
tag=${line#[.:+#%!-]}
case $line in
2020-01-31 04:03:27 +01:00
!*) [ "$tag" != "$focused" ] && s=$s" $line"
2019-09-11 04:11:40 +02:00
;;
esac
done
printf "%%{l}%s%%{F%s}%s%%{F-}\n" \
2020-01-31 04:03:27 +01:00
"$focused" "$hlwm_color9" "$s"
2019-09-11 04:11:40 +02:00
}
}
2020-05-31 04:43:23 +02:00
tags_status()
{
2019-09-11 04:11:40 +02:00
mon=$1
2020-01-31 04:03:27 +01:00
show_tags "$mon"
herbstclient -i "tag_(changed|flags)" | while read -r discard; do
show_tags "$mon"
2019-09-11 04:11:40 +02:00
done
}
2020-05-31 04:43:23 +02:00
if [ $# -ne 1 ]; then
printf "Usage: %s monitor\n" "${0##*/}" >&2
2019-09-11 04:11:40 +02:00
exit 1
fi
2020-05-31 04:43:23 +02:00
geometry=$(bar_geometry "$m")
left=
center=
right=
{
tags_status "$m" &
spoon -t &
} | while IFS= read line; do
case $line in
"%{l}"*)
left=$line
;;
"%{c}"*)
center=$line
;;
"%{r}"*)
right=$line
;;
esac
printf "%s%s%s\n" "$left" "$center" "$right"
done | lemonbar -b -g "$geometry" \
-B "$hlwm_background" -F "$hlwm_foreground" -f "$hlwm_font" &
2020-05-31 04:43:23 +02:00
2020-04-25 22:43:15 +02:00
herbstclient -w reload
2019-09-11 04:11:40 +02:00
kill 0