added scripts/core/sxmo_sws.sh sway window switcher

Signed-off-by: Stacy Harper <contact@stacyharper.net>
master
~baroque0 3 years ago committed by Stacy Harper
parent 00e495374d
commit 35b312c0b8
No known key found for this signature in database
GPG Key ID: 5BAC92328B7C5D65
  1. 49
      scripts/core/sxmo_sws.sh
  2. 2
      scripts/core/sxmo_wm.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

@ -127,7 +127,7 @@ xorgtogglelayout() {
}
swayswitchfocus() {
swaymsg focus tiling
sxmo_sws.sh
}
xorgswitchfocus() {

Loading…
Cancel
Save