From dadd29d63f7d4b6cd9f4eb397bd543c6d788d185 Mon Sep 17 00:00:00 2001 From: katherine Date: Fri, 30 Dec 2022 11:48:11 -0700 Subject: use hc for panel winlist hc using functionality added since this panel was first written? think, at least --- .config/herbstluftwm/panel.sh | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/.config/herbstluftwm/panel.sh b/.config/herbstluftwm/panel.sh index aa42a8f..d12fa77 100755 --- a/.config/herbstluftwm/panel.sh +++ b/.config/herbstluftwm/panel.sh @@ -75,36 +75,23 @@ update_taglist() { } update_winlist() { - tag_id=$(hc get_attr tags.focus.index) - focus_id=$(hc get_attr clients.focus.winid | sed 's/^0x0*//') + focus_id=$(hc get_attr clients.focus.winid) if [[ -z "$focus_id" ]]; then focus_id=0 fi - lines=$(wmctrl -l | sed -e 's/^0x0*//' -e 's/\\/\\\\/g') - - # kind of messy. use hc dump's ordering but wmctrl -l for pairing - # ids with titles - for c in $(hc dump | grep -Eo '0x[0-9a-f]*' | sed 's/^0x0*//'); do - echo "$lines" | grep "$c" - done | while read -ra line + hc list_clients | while read -r c do - # is it focussed? - if [[ "$((16#${line[0]}))" -eq "$((16#$focus_id))" ]]; then - echo -n "%{B${bg_focus} F${fg_focus}} " - else - echo -n "%{B${bg_normal} F${fg_normal}} " - fi - { - if [[ -z "${line[@]:3}" ]]; then - echo -n "(has no name)" - else - echo -n "${line[@]:3}" - fi - } | sed -r 's/(.{37})...*/\1\.\.\./' - echo -n " " - done + [[ $(($c)) -eq $(($focus_id)) ]] \ + && echo -n "%{B${bg_focus} F${fg_focus}} " \ + || echo -n "%{B${bg_normal} F${fg_normal}} " + + hc get_attr clients.$c.title | sed -r \ + -e 's/^$/(has no name)/' \ + -e 's/(.{37})...*/\1\.\.\./' + done | tr '\n' ' ' + echo -n "%{B${bg_normal} F${fg_normal}}" } -- cgit v1.2.3