diff options
| author | Robert Günzler <r@gnzler.io> | 2020-01-29 16:09:39 +0100 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2020-01-29 17:55:11 +0100 |
| commit | 5f2dbebf65dc5a2e528072a8eb0bac524d86257d (patch) | |
| tree | ef44a5412e1397b5ddcffcb8c0dfd11d89901202 /bin/swq | |
| parent | f5d56602df70950de6b7d40966b00c9939c81763 (diff) | |
Replace termify with swx
Make swq match app_ids using jq's test() which allows "fuzzy" matching
Diffstat (limited to 'bin/swq')
| -rwxr-xr-x | bin/swq | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/bin/swq b/bin/swq index 0336f64..a742d08 100755 --- a/bin/swq +++ b/bin/swq @@ -7,7 +7,7 @@ swtree() has_appid() { - swtree | jq "[ .. | select(.app_id?==\"$1\") // select(.window_properties?.class==\"$1\") // select(.window_properties?.instance==\"$1\") ]" + swtree | jq "[ .. | (select(.app_id?) | select(.app_id | test(\"$1\"))) // (select(.window_properties?.class?) | select(.window_properties.class | test(\"$1\"))) ]" } has_pid() @@ -82,16 +82,23 @@ _has() *) printf 'usage: swq has COMMAND <args>\n' printf '\nCOMMANDS:\n' - printf ' appid: returns the json of the window filtered by app_id/class\n' + printf ' appid: returns the json of the window filtered by app_id/class (fuzzy matching)\n' printf ' pid: returns the json of the window filtered by pid\n' printf ' exe: returns the json of the window filtered by process name\n' printf '\n' + exit 2 ;; esac } _latest() { - [ "$1" == "ws" ] && 1="workspace" - latest "$1" + case "$1" in + workspace|ws) latest workspace ;; + container|con) latest con ;; + output) latest output ;; + *) + printf 'usage: swq latest <con|workspace|output>\n\n' + exit 2 ;; + esac } _list() { @@ -109,7 +116,8 @@ _current() workspace) swtree | jq '.. | select(.type?=="workspace") | . as $parent | .nodes[]? | if .focused then $parent else empty end' ;; output) $0 current workspace | jq -r '.output' ;; *) - printf 'usage: swq current <con|workspace|output>\n\n' ;; + printf 'usage: swq current <con|workspace|output>\n\n' + exit 2 ;; esac } @@ -136,4 +144,5 @@ case "$1" in printf ' focus-latest-con\n' printf ' moveto <appid> <ws>: move container with <appid> to <ws>\n' printf '\n' + exit 2 ;; esac |