commit 0780f055ea90d08c54ad05700a84a08966a668e4 parent 6f7230ce2e16aebcca4d06871e7bd9874e2a80ab Author: Erik Letson <hmagellan@hmagellan.com> Date: Sun, 30 Aug 2020 17:51:58 -0500 Added option to search for class only Diffstat:
M | smartlaunch.sh | | | 19 | +++++++++++++++++-- |
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/smartlaunch.sh b/smartlaunch.sh @@ -8,11 +8,26 @@ PROPCLASS=$3 # A string that should match *THE FIRST FIELD* of 'WM_CLASS' in 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 + esac + shift +done for w in $WINIDS; do props=$(xprop -id $w | grep '^WM_NAME\|^WM_CLASS') - if [[ $props == *"WM_NAME("*") = \"$PROPNAME"* && $props == *"WM_CLASS("*") = \"$PROPCLASS"* ]]; then - EXISTS=1 + if [ $CLASSONLY -eq 0 ]; then + if [[ $props == *"WM_NAME("*") = \"$PROPNAME"* && $props == *"WM_CLASS("*") = \"$PROPCLASS"* ]]; then + EXISTS=1 + fi + else if [[ $props == *"WM_CLASS("*") = \"$PROPCLASS"* ]]; then + EXISTS=1 + fi fi done if [ $EXISTS -eq 0 ]; then