Fall back to direct execution when dbus is not installed or running
I have been using this with a dbus-less Gentoo template since the original change, and have tested recently on whonix-gw with dbus enabled and running. (cherry picked from commit bf69335074b45157734b881cc14d54ea43e7902a)
This commit is contained in:
parent
29e4ac8f97
commit
3339df739d
@ -2,18 +2,25 @@
|
|||||||
|
|
||||||
from gi.repository import Gio
|
from gi.repository import Gio
|
||||||
import sys
|
import sys
|
||||||
import dbus
|
|
||||||
|
|
||||||
def launch(desktop, *files):
|
def launch(desktop, *files):
|
||||||
launcher = Gio.DesktopAppInfo.new_from_filename(desktop)
|
launcher = Gio.DesktopAppInfo.new_from_filename(desktop)
|
||||||
if hasattr(launcher, 'get_boolean'):
|
try:
|
||||||
activatable = launcher.get_boolean('DBusActivatable')
|
import dbus
|
||||||
if activatable:
|
if hasattr(launcher, 'get_boolean'):
|
||||||
bus = dbus.SessionBus()
|
activatable = launcher.get_boolean('DBusActivatable')
|
||||||
service_id = launcher.get_id()
|
if activatable:
|
||||||
# cut the .desktop suffix
|
bus = dbus.SessionBus()
|
||||||
service_id = service_id[:-8]
|
service_id = launcher.get_id()
|
||||||
bus.start_service_by_name(service_id)
|
# cut the .desktop suffix
|
||||||
|
service_id = service_id[:-8]
|
||||||
|
try:
|
||||||
|
bus.start_service_by_name(service_id)
|
||||||
|
except dbus.DBusException:
|
||||||
|
pass
|
||||||
|
return launcher.launch(files, None)
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
launcher.launch(files, None)
|
launcher.launch(files, None)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user