hlwm: simplify panel

This commit is contained in:
Lucas 2020-05-31 02:43:23 +00:00
parent 82b8e95d7e
commit 83255497ac
2 changed files with 43 additions and 42 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
# env
# Written in 2019 by Lucas
# Written in 2019-2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved
#
# To the extent possible under law, the author(s) have dedicated all
@ -166,16 +166,6 @@ hc unlock
hc detect_monitors
if [ -f ~/.config/herbstluftwm/herbstpanel.sh ]; then
bar_height=$(($hlwm_font_height))
for m in $(hc list_monitors | cut -d : -f 1); do
hc monitor_rect "$m" | {
read -r x y w h
# `lemonbar -b` is relative from the bottom, so no need
# to do arithmetic in here
#y=$(($y + $h - $bar_height))
printf "%s\t%u\t%u\t%u\t%u\n" \
"$m" "$x" "$y" "$w" $bar_height
}
done | sh ~/.config/herbstluftwm/herbstpanel.sh &
fi
sh ~/.config/herbstluftwm/herbstpanel.sh "$m" &
done

View File

@ -1,6 +1,6 @@
#!/bin/sh
# env
# Written in 2019 by Lucas
# Written in 2019-2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved
#
# To the extent possible under law, the author(s) have dedicated all
@ -14,7 +14,16 @@ if [ -f ~/.config/herbstluftwm/theme ]; then
. ~/.config/herbstluftwm/theme
fi
show_tags() {
bar_geomtry()
{
herbstclient monitor_rect "$m" | {
read -r mx my mw mh
printf "%ux%u+%u+%u\n" "$mw" "$hlwm_font_height" "$mx" "$my"
}
}
show_tags()
{
mon=$1
herbstclient tag_status "$mon" | tr "\t" "\n" | {
focused=$(herbstclient attr tags.focus.name)
@ -33,7 +42,8 @@ show_tags() {
}
}
tags_status() {
tags_status()
{
mon=$1
show_tags "$mon"
herbstclient -i "tag_(changed|flags)" | while read -r discard; do
@ -41,12 +51,13 @@ tags_status() {
done
}
if [ $# -ne 0 ]; then
printf "Usage: %s monitor x y width height\n" "${0##*/}" >&2
if [ $# -ne 1 ]; then
printf "Usage: %s monitor\n" "${0##*/}" >&2
exit 1
fi
while IFS=" " read -r m x y w h; do
geometry=$(bar_geometry "$m")
left=
center=
right=
@ -66,8 +77,8 @@ while IFS=" " read -r m x y w h; do
;;
esac
printf "%s%s%s\n" "$left" "$center" "$right"
done | lemonbar-xft -b -g "${w}x${h}+${x}+${y}" \
done | lemonbar-xft -b -g "$geometry" \
-B "$hlwm_background" -F "$hlwm_foreground" -f "$hlwm_face" &
done
herbstclient -w reload
kill 0