blob: c3c8f579b9363a19f903416069b9b492b6aa0001 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/usr/bin/env bash
# Based on https://gist.github.com/lbonn/89d064cde963cfbacabd77e0d3801398
prompt="Switch to"
[ "$1" = "-s" ] && prompt="Swap with"
row=$(swaymsg -t get_tree | jq -r '
..
| objects
| select(.type == "workspace") as $ws
| ..
| objects
| select(has("app_id"))
| (if .focused == true then "*" else " " end) as $asterisk
| "[\($ws.name)] \($asterisk) <span weight=\"bold\">\(.app_id)</span> - \(.name) <!-- \(.id) -->\u0000icon\u001f\(.app_id)"' \
| sed 's/&/&/g' \
| rofi -i -dmenu -show-icons -markup-rows -p "$prompt")
if [ ! -z "$row" ]; then
winid=$(echo "$row" | sed 's/.*<!-- \([0-9]*\) -->.*/\1/')
if [ "$1" = "-s" ]; then
swaymsg "swap container with con_id $winid"
else
swaymsg "[con_id=$winid] focus"
fi
fi
|