.dotfiles/.config/sway/scripts/select-window

19 lines
569 B
Plaintext
Raw Permalink Normal View History

2022-01-04 15:45:42 +01:00
#!/bin/sh
# ------Get available windows:
windows=$(swaymsg -t get_tree | jq -r '
recurse(.nodes[]?) |
recurse(.floating_nodes[]?) |
select(.type=="con"), select(.type=="floating_con") |
(.id | tostring) + " " + .app_id + ": " + .name')
# ------Limit wofi's height with the number of opened windows:
height=$(echo "$windows" | wc -l)
height=$(($height + 2))
# ------Select window with wofi:
selected=$(echo "$windows" | wofi -d --lines $height -i -p "Switch to:" | awk '{print $1}')
# ------Tell sway to focus said window:
swaymsg [con_id="$selected"] focus