Closed lofidevops closed 6 years ago
@kwill: You can check whether Revolt is running by pinging it via D-Bus:
gdbus call --session \
--dest org.perezdecastro.Revolt \
--object-path /org/perezdecastro/Revolt \
--method org.freedesktop.DBus.Peer.Ping
If the D-Bus call succeeds and returns an empty tuple ()
, then Revolt is already running (as a matter of fact, the above works for many applications changing the object path and destination object). If you need to start Revolt, you can use:
flatpak run org.perezdecastro.Revolt
Another option would be making Revolt activatable over D-Bus, but the approach above does already work today.
It looks like the check is not necessary in this scenario (calling flatpak run
twice doesn't create another instance of Revolt) - but it's great to see more of how dbus and flatpak/Revolt interact, thanks! Is there a standard API and/or a Revolt-specific API for these dbus interactions?
@kwill: That's true, thanks to using GApplication
only a single instance of the application will run, so re-executing it will check for a previously launched instance and activate it.
This is the standard behavior of most programs which use GApplication
, and is not Revolt-specific. Many of the basic D-Bus methods (like .Ping
or .Activate
) are provided automatically, and applications can also expose their own additional actions.
User story: I am a software developer scripting my desktop environment. I have installed Revolt using flatpak. I want to start Revolt (unless it is already open) from a script, so that I can invoke this action along with others in a single script.
(Direct reciprocal to https://github.com/aperezdc/revolt/issues/71 :D If there's some common Flatpak/DBus interface I'm missing a link would be great.)