diff --git a/scripts/core/sxmo_sws.sh b/scripts/core/sxmo_sws.sh new file mode 100755 index 0000000..4945d25 --- /dev/null +++ b/scripts/core/sxmo_sws.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# +# Initial author: Adrien Le Guillou +# License: MIT +# +# include common definitions +# shellcheck source=scripts/core/sxmo_common.sh +. "$(dirname "$0")/sxmo_common.sh" + +set -e # error if a command as non 0 exit +set -u # error if undefined variable + + +# Default parameters +FORMAT="W:%W | %A - %T" +DMENU="sxmo_dmenu.sh" + +# FORMAT as a `jq` concatenation string +FORMAT="$FORMAT (%I)" +FORMAT=$(echo "$FORMAT" | \ + sed 's/%O/" + .output + "/ + s/%W/" + .workspace + "/ + s/%A/" + .app_id + "/ + s/%T/" + .name + "/ + s/%I/" + .id + "/ + s/"/\"/ + s/\(.*\)/\"\1\"/') + +# Get the container ID from the node tree +CON_ID=$(swaymsg -t get_tree | \ + jq -r ".nodes[] + | {output: .name, content: .nodes[]} + | {output: .output, workspace: .content.name, + apps: .content + | .. + | {id: .id?|tostring, name: .name?, app_id: .app_id?, shell: .shell?} + | select(.app_id != null or .shell != null)} + | {output: .output, workspace: .workspace, + id: .apps.id, app_id: .apps.app_id, name: .apps.name } + | $FORMAT + | tostring" | \ + $DMENU -i -p "Window Switcher") + +# Requires the actual `id` to be at the end and between paretheses +CON_ID=${CON_ID##*(} +CON_ID=${CON_ID%)} + +# Focus on the chosen window +swaymsg "[con_id=$CON_ID]" focus diff --git a/scripts/core/sxmo_wm.sh b/scripts/core/sxmo_wm.sh index b443ded..b15f6be 100644 --- a/scripts/core/sxmo_wm.sh +++ b/scripts/core/sxmo_wm.sh @@ -127,7 +127,7 @@ xorgtogglelayout() { } swayswitchfocus() { - swaymsg focus tiling + sxmo_sws.sh } xorgswitchfocus() {