.dotfiles/configs/sway/select_window.sh
2022-01-04 15:45:42 +01:00

20 lines
570 B
Bash
Executable File

#!/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