diff options
author | Justine Smithies <justine@smithies.me.uk> | 2023-10-11 18:21:52 +0100 |
---|---|---|
committer | Justine Smithies <justine@smithies.me.uk> | 2023-10-11 18:21:52 +0100 |
commit | 786f9c22fab19de866566de4c7933aef416a1462 (patch) | |
tree | 512c3563b43a511171979604d6a2a09a4b68c50a /.config/yambar/scripts/scratchpad-indicator.sh | |
parent | ba6e0a870faa3306b1e15bd03460b2faa30ceb37 (diff) |
Switched to River
Diffstat (limited to '.config/yambar/scripts/scratchpad-indicator.sh')
-rwxr-xr-x | .config/yambar/scripts/scratchpad-indicator.sh | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/.config/yambar/scripts/scratchpad-indicator.sh b/.config/yambar/scripts/scratchpad-indicator.sh new file mode 100755 index 0000000..05ba3b1 --- /dev/null +++ b/.config/yambar/scripts/scratchpad-indicator.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +output="$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?)|recurse(.floating_nodes[]?)|select(.name == "__i3_scratch").floating_nodes[]|"`<b>"+.name+"`</b> - "+.app_id+" "+(.id|tostring)')" +number="$(swaymsg -r -t get_tree | jq -r 'recurse(.nodes[]) | first(select(.name=="__i3_scratch")) | .floating_nodes | length')" + +if [ "$number" -gt 0 ]; then + text=" $number" +else + text="" +fi + +output="$(echo "$output" | sed -r 's/[&]+/and/g')" # Replace unprintable & character with the word 'and' +tooltip=" Scratchpad\n\n" +tooltip+="$(echo "$output" | sed -z 's/\n/\\n/g')" +tooltip=${tooltip::-2} + +echo "{\"text\":\"$text\", \"tooltip\":\"$tooltip\"}" +exit 0 |