fix(examples): drop the focused-dot color, the state file does not give window positions
- commit
- 4296f789810fb6faec32e37a905c110fdbefe91e
- author
- brice · · 2026-10-05 17:33 UTC
- parent
- f8cdfba
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +11 -19
M examples/bundle/left.sh +11 -19
| @@ -1,8 +1,8 @@ | |||
| 1 | 1 | #!/bin/bash | |
| 2 | 2 | # Left: the active workspace as an accent block that fades into the bar, then | |
| 3 | 3 | # the workspaces with one dot per window. The active workspace shows only its | |
| 4 | - | # dots, and the dot of the focused window is in the accent color. On NeferWL it | |
| 5 | - | # also shows the stash. Without NeferWL's state file it shows nothing. | |
| 4 | + | # dots. On NeferWL it also shows the stash. Without NeferWL's state file it | |
| 5 | + | # shows nothing. | |
| 6 | 6 | . "$(dirname "$0")/lib.sh" | |
| 7 | 7 | ||
| 8 | 8 | DOT=$ICON_DOT STASH=$ICON_STASH | |
| @@ -13,19 +13,16 @@ DOT=$ICON_DOT STASH=$ICON_STASH | |||
| 13 | 13 | ||
| 14 | 14 | draw() { | |
| 15 | 15 | # First line: "<active> <count>" of the focused output. Then one line per | |
| 16 | - | # workspace: "<n> <windows> <stashed> <focused>", where <focused> is the | |
| 17 | - | # position (from 1) of the focused window among the workspace's windows, or 0. | |
| 18 | - | local data active count n w s f line pips i color | |
| 16 | + | # workspace: "<n> <windows> <stashed>". | |
| 17 | + | local data active count n w s line pips | |
| 19 | 18 | data=$(jq -r ' | |
| 20 | 19 | .output as $o | |
| 21 | 20 | | (.outputs[] | select(.name == $o)) as $out | |
| 22 | 21 | | [.windows[] | select(.output == $o)] as $ws | |
| 23 | - | | (if .window.output == $o then .window.id else null end) as $focus | |
| 24 | 22 | | "\($out.active) \($out.count)", | |
| 25 | 23 | (range(1; $out.count + 1) as $n | |
| 26 | 24 | | [$ws[] | select(.workspace == $n)] as $here | |
| 27 | - | | (if $focus == null then null else ($here | map(.id) | index($focus)) end) as $at | |
| 28 | - | | "\($n) \($here | length) \([$here[] | select(.stash_count > 0)] | length) \(if $at == null then 0 else $at + 1 end)")' \ | |
| 25 | + | | "\($n) \($here | length) \([$here[] | select(.stash_count > 0)] | length)")' \ | |
| 29 | 26 | "$NEFERWL_STATE" 2>/dev/null) || return | |
| 30 | 27 | read -r active count <<<"$(head -1 <<<"$data")" | |
| 31 | 28 | # The state file is data, not code: bash arithmetic runs command | |
| @@ -33,23 +30,18 @@ draw() { | |||
| 33 | 30 | [[ $active =~ ^[0-9]+$ && $count =~ ^[0-9]+$ ]] || return | |
| 34 | 31 | ||
| 35 | 32 | line="$(bg "$ACCENT")$(fg "$(ink "$ACCENT")")$BOLD $active $RESET$(fade "$ACCENT" "$BAR")$(bg "$BAR")" | |
| 36 | - | while read -r n w s f; do | |
| 37 | - | [[ $n =~ ^[0-9]+$ && $w =~ ^[0-9]+$ && $s =~ ^[0-9]+$ && $f =~ ^[0-9]+$ ]] || continue | |
| 38 | - | # At most 4 dots; a focused window past the 4th is shown on the 4th. | |
| 33 | + | while read -r n w s; do | |
| 34 | + | [[ $n =~ ^[0-9]+$ && $w =~ ^[0-9]+$ && $s =~ ^[0-9]+$ ]] || continue | |
| 35 | + | # One dot per window, at most 4. | |
| 39 | 36 | pips="" | |
| 40 | - | for ((i = 1; i <= (w > 4 ? 4 : w); i++)); do | |
| 41 | - | color=$DIM | |
| 42 | - | ((n == active)) && color=$NEFERBAR_FOREGROUND | |
| 43 | - | ((i == (f > 4 ? 4 : f))) && color=$ACCENT | |
| 44 | - | pips+="$(fg "$color")$DOT" | |
| 45 | - | done | |
| 37 | + | ((w > 0)) && printf -v pips "$DOT%.0s" $(seq 1 $((w > 4 ? 4 : w))) | |
| 46 | 38 | if ((n == active)); then | |
| 47 | 39 | # The number is already in the accent block on the left. | |
| 48 | - | line+=" $pips" | |
| 40 | + | line+="$(fg "$NEFERBAR_FOREGROUND") $pips" | |
| 49 | 41 | ((s > 0)) && line+="$(fg "$NEFERBAR_COLOR2") $STASH$s" | |
| 50 | 42 | line+=" " | |
| 51 | 43 | elif ((w > 0)); then | |
| 52 | - | line+="$(fg "$NEFERBAR_FOREGROUND") $n $pips " | |
| 44 | + | line+="$(fg "$NEFERBAR_FOREGROUND") $n $(fg "$DIM")$pips " | |
| 53 | 45 | else | |
| 54 | 46 | line+="$(fg "$DIM") $n " | |
| 55 | 47 | fi | |
| @@ -1,8 +1,8 @@ | |||||
| 1 | #!/bin/bash | 1 | #!/bin/bash | ||
| 2 | # Left: the active workspace as an accent block that fades into the bar, then | 2 | # Left: the active workspace as an accent block that fades into the bar, then | ||
| 3 | # the workspaces with one dot per window. The active workspace shows only its | 3 | # the workspaces with one dot per window. The active workspace shows only its | ||
| 4 | - | # dots, and the dot of the focused window is in the accent color. On NeferWL it | 4 | + | # dots. On NeferWL it also shows the stash. Without NeferWL's state file it |
| 5 | - | # also shows the stash. Without NeferWL's state file it shows nothing. | 5 | + | # shows nothing. |
| 6 | . "$(dirname "$0")/lib.sh" | 6 | . "$(dirname "$0")/lib.sh" | ||
| 7 | 7 | ||||
| 8 | DOT=$ICON_DOT STASH=$ICON_STASH | 8 | DOT=$ICON_DOT STASH=$ICON_STASH | ||
| @@ -13,19 +13,16 @@ DOT=$ICON_DOT STASH=$ICON_STASH | |||||
| 13 | 13 | ||||
| 14 | draw() { | 14 | draw() { | ||
| 15 | # First line: "<active> <count>" of the focused output. Then one line per | 15 | # First line: "<active> <count>" of the focused output. Then one line per | ||
| 16 | - | # workspace: "<n> <windows> <stashed> <focused>", where <focused> is the | 16 | + | # workspace: "<n> <windows> <stashed>". |
| 17 | - | # position (from 1) of the focused window among the workspace's windows, or 0. | 17 | + | local data active count n w s line pips |
| 18 | - | local data active count n w s f line pips i color | |||
| 19 | data=$(jq -r ' | 18 | data=$(jq -r ' | ||
| 20 | .output as $o | 19 | .output as $o | ||
| 21 | | (.outputs[] | select(.name == $o)) as $out | 20 | | (.outputs[] | select(.name == $o)) as $out | ||
| 22 | | [.windows[] | select(.output == $o)] as $ws | 21 | | [.windows[] | select(.output == $o)] as $ws | ||
| 23 | - | | (if .window.output == $o then .window.id else null end) as $focus | |||
| 24 | | "\($out.active) \($out.count)", | 22 | | "\($out.active) \($out.count)", | ||
| 25 | (range(1; $out.count + 1) as $n | 23 | (range(1; $out.count + 1) as $n | ||
| 26 | | [$ws[] | select(.workspace == $n)] as $here | 24 | | [$ws[] | select(.workspace == $n)] as $here | ||
| 27 | - | | (if $focus == null then null else ($here | map(.id) | index($focus)) end) as $at | 25 | + | | "\($n) \($here | length) \([$here[] | select(.stash_count > 0)] | length)")' \ |
| 28 | - | | "\($n) \($here | length) \([$here[] | select(.stash_count > 0)] | length) \(if $at == null then 0 else $at + 1 end)")' \ | |||
| 29 | "$NEFERWL_STATE" 2>/dev/null) || return | 26 | "$NEFERWL_STATE" 2>/dev/null) || return | ||
| 30 | read -r active count <<<"$(head -1 <<<"$data")" | 27 | read -r active count <<<"$(head -1 <<<"$data")" | ||
| 31 | # The state file is data, not code: bash arithmetic runs command | 28 | # The state file is data, not code: bash arithmetic runs command | ||
| @@ -33,23 +30,18 @@ draw() { | |||||
| 33 | [[ $active =~ ^[0-9]+$ && $count =~ ^[0-9]+$ ]] || return | 30 | [[ $active =~ ^[0-9]+$ && $count =~ ^[0-9]+$ ]] || return | ||
| 34 | 31 | ||||
| 35 | line="$(bg "$ACCENT")$(fg "$(ink "$ACCENT")")$BOLD $active $RESET$(fade "$ACCENT" "$BAR")$(bg "$BAR")" | 32 | line="$(bg "$ACCENT")$(fg "$(ink "$ACCENT")")$BOLD $active $RESET$(fade "$ACCENT" "$BAR")$(bg "$BAR")" | ||
| 36 | - | while read -r n w s f; do | 33 | + | while read -r n w s; do |
| 37 | - | [[ $n =~ ^[0-9]+$ && $w =~ ^[0-9]+$ && $s =~ ^[0-9]+$ && $f =~ ^[0-9]+$ ]] || continue | 34 | + | [[ $n =~ ^[0-9]+$ && $w =~ ^[0-9]+$ && $s =~ ^[0-9]+$ ]] || continue |
| 38 | - | # At most 4 dots; a focused window past the 4th is shown on the 4th. | 35 | + | # One dot per window, at most 4. |
| 39 | pips="" | 36 | pips="" | ||
| 40 | - | for ((i = 1; i <= (w > 4 ? 4 : w); i++)); do | 37 | + | ((w > 0)) && printf -v pips "$DOT%.0s" $(seq 1 $((w > 4 ? 4 : w))) |
| 41 | - | color=$DIM | |||
| 42 | - | ((n == active)) && color=$NEFERBAR_FOREGROUND | |||
| 43 | - | ((i == (f > 4 ? 4 : f))) && color=$ACCENT | |||
| 44 | - | pips+="$(fg "$color")$DOT" | |||
| 45 | - | done | |||
| 46 | if ((n == active)); then | 38 | if ((n == active)); then | ||
| 47 | # The number is already in the accent block on the left. | 39 | # The number is already in the accent block on the left. | ||
| 48 | - | line+=" $pips" | 40 | + | line+="$(fg "$NEFERBAR_FOREGROUND") $pips" |
| 49 | ((s > 0)) && line+="$(fg "$NEFERBAR_COLOR2") $STASH$s" | 41 | ((s > 0)) && line+="$(fg "$NEFERBAR_COLOR2") $STASH$s" | ||
| 50 | line+=" " | 42 | line+=" " | ||
| 51 | elif ((w > 0)); then | 43 | elif ((w > 0)); then | ||
| 52 | - | line+="$(fg "$NEFERBAR_FOREGROUND") $n $pips " | 44 | + | line+="$(fg "$NEFERBAR_FOREGROUND") $n $(fg "$DIM")$pips " |
| 53 | else | 45 | else | ||
| 54 | line+="$(fg "$DIM") $n " | 46 | line+="$(fg "$DIM") $n " | ||
| 55 | fi | 47 | fi | ||