26 lines
727 B
Bash
Executable file
26 lines
727 B
Bash
Executable file
#!/bin/sh
|
|
|
|
menu=$1
|
|
|
|
entries=$(swaymsg -t get_tree | \
|
|
jq --unbuffered --compact-output '( select(.name == "root") | .nodes[] | select(.name == "__i3") | .nodes[] | select(.name == "__i3_scratch") | .focus) as $scratch_ids | [.. | (.nodes? + .floating_nodes?) // empty | .[] | select(.id |IN($scratch_ids[]))] as $scratch_nodes | $scratch_nodes | length'
|
|
)
|
|
|
|
case $entries in
|
|
0)
|
|
exit
|
|
;;
|
|
1)
|
|
swaymsg scratchpad show
|
|
exit
|
|
;;
|
|
esac
|
|
|
|
swaymsg -t get_tree | \
|
|
jq -r 'recurse(.nodes[]?) | select(.name == "__i3_scratch").floating_nodes[] | [.id,"["+.app_id+"]",.name] | join("\t")' | \
|
|
$menu -dmenu | \
|
|
{
|
|
read -r con_id app_id name
|
|
swaymsg "[con_id=$con_id] scratchpad show"
|
|
}
|