Skip to content

Commit

Permalink
mkropat#11 minimize flag
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
e3rd committed Jan 28, 2016
1 parent a72766f commit 90021f6
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions jumpapp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 ;;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 90021f6

Please sign in to comment.