diff options
Diffstat (limited to '')
| -rwxr-xr-x | bin/swq | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/bin/swq b/bin/swq index a742d08..ba6e382 100755 --- a/bin/swq +++ b/bin/swq @@ -49,6 +49,9 @@ has_exe() fi has_pid "$pid_of_win" } +has_ws() { + swtree | jq "[ .. | select(.type?==\"workspace\" and .name?==\"$1\") ]" +} latest() { @@ -79,12 +82,14 @@ _has() appid) has_appid "$2" ;; pid) has_pid "$2";; exe) has_exe "$2";; + ws) has_ws "$2";; *) printf 'usage: swq has COMMAND <args>\n' printf '\nCOMMANDS:\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 ' pid: returns json of the window filtered by pid\n' + printf ' exe: returns json of the window filtered by process name\n' + printf ' ws: returns json of the window filtered by workspace\n' printf '\n' exit 2 ;; esac @@ -110,10 +115,10 @@ _current() { case "$1" in window) _current con ;; - con) swtree | jq '.. | select(.type?=="con" and .focused?==true)' ;; + con) swtree | jq '.. | select((.type? | test("con")?) and .focused?)' ;; ws) _current workspace ;; - workspace) swtree | jq '.. | select(.type?=="workspace") | . as $parent | .nodes[]? | if .focused then $parent else empty end' ;; + workspace) swtree | jq '.. | select(.type?=="workspace") | . as $parent | $parent.nodes[]?, $parent.floating_nodes[]? | if .focused? then $parent else empty end' ;; output) $0 current workspace | jq -r '.output' ;; *) printf 'usage: swq current <con|workspace|output>\n\n' |