summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/focus_app.sh12
1 files changed, 6 insertions, 6 deletions
diff --git a/scripts/focus_app.sh b/scripts/focus_app.sh
index 955a15d..11c23c4 100755
--- a/scripts/focus_app.sh
+++ b/scripts/focus_app.sh
@@ -1,9 +1,9 @@
-APP=$1
-WID=$(xdotool search --class "$APP" | head -n 1)
-
-if [ -z "$WID" ]; then
- nohup $APP &>/dev/null &
+if xdotool search --class "firefox" getwindowname %@ | grep -q "firefox"; then
+if xdotool search --onlyvisible --class "firefox" windowactivate %@; then
+ echo "firefox is focused. Minimizing."
+ xdotool search --onlyvisible --class "firefox" windowminimize %@
else
- xdotool windowactivate "$WID"
+ echo "firefox is open but not focused. Focusing the existing instance."
+ xdotool search --class "firefox" windowactivate %@
fi