[Gambas-devel] gb.desktop detect a running application

Benoît Minisini gambas at ...1...
Mon Aug 27 10:47:39 CEST 2012


Le 27/08/2012 07:05, Sebastian Kulesz a écrit :
> I found on the TODO an entry for the gb.desktop component:
> - Detect an already running application.
>
> I had a need for that on another project. Is this what you are looking for?
>
> ----------
>
> Public Function isRunning(sProcess as String) As Boolean
>
>    Dim sOutput As String
>
>    Exec ["pgrep", "-x", "-c", Shell(sProcess)] To sOutput
>
>    If CInt(Trim(sOutput)) > 0 Then Return True
>
>    Return False
>
> End
>
> ----------
>

Not at all.

A X11 desktop is a server whose applications do not necessarily come 
from the same client.

So to detect that an application is already running is tricky: two 
processes from the same executable on the same machine can run on two 
different desktops, how could you know that?

I think that an X11 application can register some properties on the root 
windows so that it knows that it already runs on that desktop. I think 
it may be a standard, but I don't go deeper than that at the moment.

Otherwise, this split between the desktop (X11) and the systems that run 
the application seems to be dumped with D-Bus and Wayland, so let's see!

Regards,

-- 
Benoît Minisini




More information about the Devel mailing list