Return to repo list

smartlaunch

Contextual launcher/tag shortcut methodology; intended for dwm.
Return to HMagellan.com

commit 8c76b979e8201e0b14d50e4eb6f3b0ec72955a75
parent 0780f055ea90d08c54ad05700a84a08966a668e4
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Sun, 30 Aug 2020 17:56:25 -0500

Reformat for options

Diffstat:
Msmartlaunch.sh | 26+++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/smartlaunch.sh b/smartlaunch.sh @@ -2,19 +2,35 @@ # To use the script, bind it to a key combination in dwm's config.h, and also bind THE SAME KEY to switch to the dedicated tag for the window to be launched. -CMDNAME=$1 # The command to execute if no matching window is found. -PROPNAME=$2 # A string that should match 'WM_NAME' for the target window, in whole or in part. See xprop(1). -PROPCLASS=$3 # A string that should match *THE FIRST FIELD* of 'WM_CLASS' in the target window, in whole or in part. See xprop(1) +# Import pre-emptive values +CLASSONLY=0 + +# Opts +while [[ "$#" -gt 0 ]]; do + case $1 in + -C|--classonly) + CLASSONLY=1; shift ;; + esac + shift +done + +if [ $CLASSONLY -eq 0 ]; then + CMDNAME=$1 # The command to execute if no matching window is found. + PROPNAME=$2 # A string that should match 'WM_NAME' for the target window, in whole or in part. See xprop(1). + PROPCLASS=$3 # A string that should match *THE FIRST FIELD* of 'WM_CLASS' in the target window, in whole or in part. See xprop(1) +else + CMDNAME=$1 # The command to execute if no matching window is found. + PROPCLASS=$2 # A string that should match *THE FIRST FIELD* of 'WM_CLASS' in the target window, in whole or in part. See xprop(1) +fi WINIDS=$(xwininfo -root -tree | grep -o '^[[:space:]]*0x.\{7\}') EXISTS=0 -CLASSONLY=0 # Opts while [[ "$#" -gt 0 ]]; do case $1 in -C|--classonly) - CLASSONLY=1 + CLASSONLY=1; shift ;; esac shift done