Hi, I need some help around launching an app from another app within the same snap.
I have a strict snap with two apps:
- A user daemon (uses the experimental user daemon snapd feature). This user service starts automatically on login and does most of the work, including posting desktop notifications to keep the user informed.
- A GTK3 GUI app. This is just a view that lets the user visualize what the daemon is doing. The user can launch and close it without affecting the daemon in any way. This GUI app has a properly composed/configured desktop file with icon, etc.
My use case for this post: When the user daemon posts a desktop notification, I want the user to be able to click on the notification (default action) in order to launch the GUI app.
I’ve already wired up the default notification action on the daemon to launch the GUI app by executing the same command as specified for that app in snapcraft.yaml. This works fine, however the window manager doesn’t decorate the app’s window with its icon (from the desktop file). Instead, it gets a default “executable” icon. This is unacceptable for me, as it hurts user experience.
So my next idea was to add the
desktop-launch plug to my user daemon, connect it manually, and invoke
io.snapcraft.PrivilegedDesktopLauncher.OpenDesktopEntry (specifying the GUI app’s desktop file ID). This works perfectly (the app gets launched the same way as if the user launched it, and the app’s window is decorated with the icon as expected). This means, however, that I will need to request permission to use
desktop-launch in my snap AND have the user connect it manually. Not great.
My question is: Is there a better/different way, without requiring a manually-connected privileged interface, for app A to launch app B using B’s desktop file (all within the same snap)? The goal is to achieve the exact same effect as when the user launches the GUI app via its desktop launcher.
Thanks in advance.