diff options
| author | Robert Günzler <r@gnzler.io> | 2020-07-07 18:08:43 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2020-07-07 18:08:43 +0200 |
| commit | ecfb84d06395d98bb30d248269774edc15feb728 (patch) | |
| tree | f1116c9cfcc8f5105470d5a257c19b262b7551da | |
| parent | 2f2c0ab361fb31edd2fe5c39281c5150411c1d9a (diff) | |
bin/swq: make current workspace detection more robust
| -rwxr-xr-x | bin/swq | 6 |
1 files 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 <appid> <ws>: move container with <appid> to <ws>\n' printf '\n' exit 2 ;; + + *) swtree ;; esac |