From ecfb84d06395d98bb30d248269774edc15feb728 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Tue, 7 Jul 2020 18:08:43 +0200 Subject: bin/swq: make current workspace detection more robust --- bin/swq | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/swq b/bin/swq index 39a594a..85f11a7 100755 --- a/bin/swq +++ b/bin/swq @@ -118,7 +118,7 @@ _current() con) swtree | jq '.. | select((.type? | test("con")?) and .focused?)' ;; ws) _current workspace ;; - workspace) swtree | jq '.. | select(.type?=="workspace") | . as $parent | $parent.nodes[]?, $parent.floating_nodes[]? | if .focused? then $parent else empty end' ;; + workspace) swtree | jq '.. | select(.type?=="workspace") | . as $parent | .. | select(.focused?==true) | $parent' ;; output) $0 current workspace | jq -r '.output' ;; output-full) $0 list output | jq ".[] | select((.type?==\"output\") and (.name?==\"$($0 current output)\"))" ;; *) @@ -136,7 +136,7 @@ case "$1" in focus-latest-con) sway [con_id="$(latest con | jq -r '.id')"] focus ;; moveto) shift; moveto $@ ;; - *) + -h|--help|help) printf 'usage: swq COMMAND\n' printf '\n' printf 'QUERY COMMANDS:\n' @@ -151,4 +151,6 @@ case "$1" in printf ' moveto : move container with to \n' printf '\n' exit 2 ;; + + *) swtree ;; esac -- cgit 1.4.1