From 50f7bd809a5b1f754b5e755cbca2ec517e94eae5 Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Wed, 14 Jun 2023 02:05:36 -0400 Subject: [PATCH] Work on Sway support for the window lister. Unfortunately, most of the window IDs that get returned are "None" so you can't actually select the window, but it does list them now. --- scripts/window_list.sh | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/scripts/window_list.sh b/scripts/window_list.sh index bbcbf94..196c505 100755 --- a/scripts/window_list.sh +++ b/scripts/window_list.sh @@ -1,5 +1,9 @@ #!/usr/bin/env bash +path="$(readlink -f $0)" +path="${path%/*/*}" +path="${path##*/}" +if [[ "$path" == "i3" ]]; then mapfile -t windowList < <(python3 -c ' import i3ipc @@ -13,11 +17,28 @@ id="$(yad --title "I38" --list --separator "" --column "id" --column "Select Win if [[ -z "${id}" ]]; then exit 0 fi -path="$(readlink -f $0)" -path="${path%/*/*}" -path="${path##*/}" -if [[ "$path" == "i3" ]]; then i3-msg \[id="${id}"\] focus else - swaymsg \[id="${id}"\] focus +mapfile -t windowList < <(python3 -c ' +import i3ipc + +i3 = i3ipc.Connection() + +for con in i3.get_tree(): + if con.window or con.type == "con": + if con.name: + print(con.window) + print(con.name)') + +# Remove the first entry if it is "none" +if [[ "${windowList[0]}" == "none" ]]; then + unset "windowList[0]" +fi + +id="$(yad --title "I38" --list --separator "" --column "id" --column "Select Window" --hide-column 1 --print-column 1 "${windowList[@]}")" + +if [[ -z "${id}" ]]; then + exit 0 +fi +swaymsg \[id="${id}"\] focus fi