~mil/sxmo-utils

35b312c0b8852ce7addd086ac53713fabb3a6c2d — ~baroque0 23 days ago 00e4953
added scripts/core/sxmo_sws.sh sway window switcher

Signed-off-by: Stacy Harper <contact@stacyharper.net>
2 files changed, 50 insertions(+), 1 deletions(-)

A scripts/core/sxmo_sws.sh
M scripts/core/sxmo_wm.sh
A scripts/core/sxmo_sws.sh => scripts/core/sxmo_sws.sh +49 -0
@@ 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

M scripts/core/sxmo_wm.sh => scripts/core/sxmo_wm.sh +1 -1
@@ 127,7 127,7 @@ xorgtogglelayout() {
}

swayswitchfocus() {
	swaymsg focus tiling
	sxmo_sws.sh
}

xorgswitchfocus() {