diff --git a/xdg-config-dir/herbstluftwm/autostart b/xdg-config-dir/herbstluftwm/autostart index add75a3..a969fff 100755 --- a/xdg-config-dir/herbstluftwm/autostart +++ b/xdg-config-dir/herbstluftwm/autostart @@ -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 +for m in $(hc list_monitors | cut -d : -f 1); do + sh ~/.config/herbstluftwm/herbstpanel.sh "$m" & +done diff --git a/xdg-config-dir/herbstluftwm/herbstpanel.sh b/xdg-config-dir/herbstluftwm/herbstpanel.sh index 3871fc6..89a8476 100644 --- a/xdg-config-dir/herbstluftwm/herbstpanel.sh +++ b/xdg-config-dir/herbstluftwm/herbstpanel.sh @@ -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,33 +51,34 @@ 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 - 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-xft -b -g "${w}x${h}+${x}+${y}" \ - -B "$hlwm_background" -F "$hlwm_foreground" -f "$hlwm_face" & -done +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-xft -b -g "$geometry" \ + -B "$hlwm_background" -F "$hlwm_foreground" -f "$hlwm_face" & + herbstclient -w reload kill 0