diff options
author | sefidel <contact@sefidel.net> | 2024-09-04 01:15:08 +0900 |
---|---|---|
committer | sefidel <contact@sefidel.net> | 2024-09-04 20:46:57 +0900 |
commit | abc0aee028707ff881b04ff1a85eb0b655f15bfe (patch) | |
tree | 8dcf6a6fa411035c5fba5353f0e23b36a9cc768a /home/profiles/gui/scripts/scratchpad-indicator.nix | |
parent | fb1fa5466912bb4211b4ca61be532725a79172ed (diff) | |
download | nixrc-abc0aee028707ff881b04ff1a85eb0b655f15bfe.tar.gz nixrc-abc0aee028707ff881b04ff1a85eb0b655f15bfe.zip |
feat(home/gui): waybar: add scratchpad indicator
Diffstat (limited to 'home/profiles/gui/scripts/scratchpad-indicator.nix')
-rw-r--r-- | home/profiles/gui/scripts/scratchpad-indicator.nix | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/home/profiles/gui/scripts/scratchpad-indicator.nix b/home/profiles/gui/scripts/scratchpad-indicator.nix new file mode 100644 index 0000000..7ee66c3 --- /dev/null +++ b/home/profiles/gui/scripts/scratchpad-indicator.nix @@ -0,0 +1,18 @@ +'' +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 +'' |