Inconsistent Launch of Applications using gi.repository.Gio.DesktopAppInfo.launch
Hi all,
I am trying to use the following code snippet to open an application in Gio:
from gi.repository import Gio
status = Gio.DesktopAppInfo.new('org.gnome.gedit.desktop').launch()
if not status:
print("unable to launch application")
I expect this code to open a new instance of the Gedit application and create a new document within that instance. However, if there is no existing instance of Gedit running, executing the code once doesn't produce any results. I have to run the code twice to achieve the desired outcome. If I run the code three times in a row, only two tabs open in Gedit instead of the expected three.
I have observed that this issue is not limited to Gedit. The Backup application in Ubuntu (Déjà Dup Backups version 42.9 on my machine) has the same problem, and there are a few other applications as well. Some applications, such as org.gnome.Calculator.desktop
version 41.1, work fine.
I used Gio.DesktopAppInfo.get_all()
and app.get_id()
to list the applications, and experimented on some of them. When the application is not opened, no error is reported from PyGObject (status
is True
).
I am aware that failure detection is not always possible (from https://lazka.github.io/pgi-docs/Gio-2.0/classes/AppInfo.html#Gio.AppInfo.launch) :
Note that even if the launch is successful the application launched can fail to start if it runs into problems during startup. There is no way to detect this.
I do not believe that this failure, which is systematic for certain applications but not across all applications, is normal. I have created this issue to address it.
I have been trying to find more debugging information, but the above quote suggests that I may not find any. Is there a way to obtain debugging information from another source?
System information :
- Ubuntu 22.04.1
- Gnome 42.5
- X11
- X.Org 1.21.1.3
- Calculator 41.1
- Déjà Dup Backups 42.9
- Gedit 41.0
- python 3.10.6
- PyGObject 3.42.1
- pycairo 1.20.1
- version from apt info for python3-gi: 3.42.1-0ubuntu1
- version from apt info for python3-gi-cairo: 3.42.1-0ubuntu1
- version from apt info for gir1.2-gtk-3.0: 3.24.33-1ubuntu2
- version from apt info for libgirepository1.0-dev: 1.72.0-1
- version from apt info for libcairo2-dev: 1.16.0-5ubuntu2