Cancel the startup notification on "launch-failed" signal

I’m using g_app_info_launch () and connect to AppLaunchContext ::launched and AppLaunchContext ::launch-failed. I noticed that when the launch fails, GNOME Shell still uses a spinning cursor for a few seconds. I suspect that’s because it doesn’t know that the launch failed. The documentation of the launch-failed signal says:

The startup notification id is provided, so that the launcher can cancel the startup notification.

So it seems like it’s my job to cancel the startup notification (even though I didn’t start it, that seems to be done automatically by g_app_info_launch). How can I do that? What function do I have to call?

The startup notification handling is done within GTK and GLib, and you shouldn’t need to cancel it yourself.

Whether startup notification works depends on several factors, though:

  • How the app is being launched (D-Bus activation or g_spawn())
  • What windowing system you’re using (X11 or Wayland; they both have different startup notification protocols)
  • Whether the app being launched supports startup notification (all GTK apps do; apps using other toolkits may or may not)

Thanks for the reply!

The startup notification handling is done within GTK and GLib, and you shouldn’t need to cancel it yourself.

What does the sentence “The startup notification id is provided, so that the launcher can cancel the startup notification.” in the documentation mean then?

Whether startup notification works depends on several factors, though:

How the app is being launched (D-Bus activation or g_spawn())
What windowing system you’re using (X11 or Wayland; they both have different startup notification protocols)
Whether the app being launched supports startup notification (all GTK apps do; apps using other toolkits may or may not)

The app in question uses D-Bus activation, is a GTK app and the windowing system is Wayland. Startup notification seems to work fine if the app starts successfully but as I described in my initial post, when the app fails to start, GNOME Shell keeps using a spinning cursor for some time (about 15 seconds), which I interpret as “the startup notification is not canceled until a timeout occurs”, even though the launch-failed signal is sent immediately. Is that a bug? Should I open a ticket somewhere?

Looks like hastily-written documentation which is focused more on the implementer of the startup notification spec than the user of GLib. MRs welcome to improve it.

iirc there are some odd behaviours around startup notifications in some cases, but I can’t remember what they are. A gnome-shell developer may have that knowledge paged in.

You could investigate yourself by recording D-Bus traffic during app start (on the system and session buses) using D-Feet, and looking to see what your app does when startup fails. In particular, the startup notification messages sent to/from gnome-session.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.