[Gambas-user] Single instance application, anyone else done it?

Bruce Steers bsteers4 at gmail.com
Wed Jul 7 12:24:14 CEST 2021

Hi all,
I'm looking for a sure fire recommended way to make an application a
"Single Instance" application that takes filepath args.

The Reason:
If i create a desktop launcher for my app and drop multiple files on it
linux does not launch the application once and send all the dropped file
paths to it.  it launches the application multiple times all with one file
So i needed a way to only let one app launch and the other instances just
send the file args to the first instance.

Currently i have used a pipe and Shell "pgrep -f AppName" to list all app
id's the lowest app id is selected as the working app and any other
instances of the app launched are quickly closed after sending their file
args to the pipe.
Then the first app picks up the file args from the pipe file.
(example app here... https://forum.gambas.one/viewtopic.php?f=13&t=1149)

I'm currently looking into DBus as a better alternative for detecting an
already loaded app and sending it args but i'm making slow progress with
DBus atm (any simple app DBus communication examples would be handy)

Just wondered if anyone here has done this sort of thing already and may
have any advice / examples.

Cheers in advance :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210707/3e3aace8/attachment.htm>

More information about the User mailing list