One of best parts of using Linux Mint is its Web Apps Manager.

I can use most of my websites as dedicated applications now.
Case in point, I use a dedicated web app to run Elk, the web client for Mastodon.
Social stuff like this, or banking stuff or my webmail for that matter, stays away from the rest of my browsing and lets me keep these activities cognitively separate.



So far, so good.
The issue arises, when I try to launch one of these dedicated apps and it is already running.
Due to the way these little web containers are created, it cannot run another instance and I run into this error.

“Firefox is already running, but is not responding. To use Firefox, you must first close the existing Firefox process, restart your device, or use a different profile.”1



And I’m like, I know this you git! I am running a different profile. Can’t you just switch to it? Apparently it cannot. So I’d have to go looking for my app and then Alt-Tab through dozens of windows or look in my dock2 and then get it back.


The problem wasn’t the error per se, the problem was the slightly longish delay between me calling the app and the error popping up. And also all that crazy hunting and pecking to find the right window, once I see the error. It gets maddening when I need to do this dance and all I want to do is get to my email window to go look for something important.

So I began casting around for a way to somehow switch to the actually running window. Was it possible?
That’s when I found xdotool
It lets you do all sorts of crazy things with windows and keyboard and mouse input, but most importantly for me, it let me search for my running app window and it let me raise and bring it back up. Awesome!

So instead of telling Ulauncher to directly launch the app, I told it to run this script instead.


pic of the ulauncher script window
1
2
3
4
5
6
7
8
9
#!/usr/bin/env bash 

export ELKWINID=$(xdotool search WebApp-ElkforToots1234 | tail -n1)

if [ $ELKWINID ]; then
    xdotool windowactivate $ELKWINID
else
    sh -c ' firefox --class WebApp-ElkforToots1234 --profile /home/user/.local/share/ice/firefox/ElkforToots1234 --no-remote "https://elk.zone/"'
fi

In a nutshell, I’m looking to see if Elk is already running (using the xdotool search option in line 3).
If it is, I tell xdotool to get that window to the forefront of the display; and if it isn’t, then to just go ahead and launch the app anew.

What a load off my mind, this one was!


Feedback on this post? Mail me at feedback@janusworx.com

P.S. Subscribe to my mailing list!
Forward these posts and letters to your friends and get them to subscribe!
P.P.S. Feed my insatiable reading habit.


  1. I don’t know if this would happen if I use Chrome as the browser engine. I don’t even use it as a browser, much. And for things like these, I wouldn’t touch it with a ten foot pole. ↩︎

  2. and still some how miss it ↩︎