diff options
author | katherine <ageha@airen-no-jikken.icu> | 2022-12-30 11:48:11 -0700 |
---|---|---|
committer | katherine <ageha@airen-no-jikken.icu> | 2022-12-30 11:48:11 -0700 |
commit | dadd29d63f7d4b6cd9f4eb397bd543c6d788d185 (patch) | |
tree | 6142fa34419c0f6d8457c274839cedabacb6eb6a | |
parent | d1bf3c5d667d64bdfb3aeb1afa7553f0ea3ca666 (diff) | |
download | dotfiles-dadd29d63f7d4b6cd9f4eb397bd543c6d788d185.tar.gz |
use hc for panel winlist
hc using functionality added since this panel was first written? think,
at least
-rwxr-xr-x | .config/herbstluftwm/panel.sh | 35 |
1 files 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}}" } |