From 90021f6c7b5902834de94d337a1c31f736b394f5 Mon Sep 17 00:00:00 2001 From: e3rd Date: Thu, 28 Jan 2016 14:30:50 +0100 Subject: [PATCH] #11 minimize flag I won't use this personally but if you find it useful for others, you may grant this. If a single window is already open and in focus - minimize it instead if m flag is present. --- jumpapp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/jumpapp b/jumpapp index 7ce262a..588e8d7 100755 --- a/jumpapp +++ b/jumpapp @@ -10,6 +10,7 @@ Otherwise, launch COMMAND (with opitonal ARGs) to start the application. Options: -r -- cycle through windows in reverse order -f -- force COMMAND to launch if process found but no windows found + -m -- if a single window is already open and in focus - minimize it -n -- do not fork into background when launching COMMAND -p -- always launch COMMAND when ARGs passed (see Argument Passthrough in man page) @@ -21,16 +22,17 @@ Options: } main() { - local classid cmdid force fork=1 list passthrough in_reverse matching_title workspace_filter + local classid cmdid force fork=1 list passthrough focusOrMinimize in_reverse matching_title workspace_filter local OPTIND - while getopts c:fhi:Lnprt:w opt; do + while getopts c:fhi:Lmnprt:w opt; do case "$opt" in c) classid="$OPTARG" ;; f) force=1 ;; h) show_usage; exit 0 ;; i) cmdid="$OPTARG" ;; L) list=1 ;; + m) focusOrMinimize=1 ;; n) fork='' ;; p) passthrough=1; force=1 ;; # passthrough implies force r) in_reverse=1 ;; @@ -70,8 +72,18 @@ jumpapp() { local pids=( $(list_pids_for_command "$cmdid") ) local windowids=( $(list_matching_windows "$classid" "${pids[@]}" | select_windowid) - ) - + ) + + if [[ -n "$focusOrMinimize" ]]; then + if [[ ${#windowids[@]} -eq "1" ]]; then + if [[ "$(get_active_windowid)" -eq "${windowids[0]}" ]]; then + echo "zde" + echo $(get_active_windowid) + wmctrl -i -r $(get_active_windowid) -b toggle,shaded + fi + fi + fi + if [[ -n "$list" ]]; then printf 'Matched Windows [%d]\n' ${#windowids[@]} list_matching_windows "$classid" "${pids[@]}" | print_windows