blob: 8fd06f488cdd3ff6d270b07c6220aaafe0a5ca99 (
plain) (
tree)
|
|
#!/bin/bash
# Scratchpad indicator for Sway
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="\n"
tooltip+="$(echo "$output" | sed -z 's/\n/\\n/g')"
tooltip=${tooltip::-2}
function ShowInfo() {
if [ "$number" -eq 0 ]; then
exit
else
tooltip="$(echo -e $tooltip)"
notify-send --hint=string:x-canonical-private-synchronous:scratchpad -u normal " Scratchpad" "$tooltip"
fi
}
function Update() {
printf "%s" "$text"
}
if [ "$1" = "ShowInfo" ]; then
ShowInfo
else
Update
fi
|