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,10 +2,11 @@
|
|||||||
|
|
||||||
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)
|
||||||
|
try:
|
||||||
|
import dbus
|
||||||
if hasattr(launcher, 'get_boolean'):
|
if hasattr(launcher, 'get_boolean'):
|
||||||
activatable = launcher.get_boolean('DBusActivatable')
|
activatable = launcher.get_boolean('DBusActivatable')
|
||||||
if activatable:
|
if activatable:
|
||||||
@ -13,7 +14,13 @@ def launch(desktop, *files):
|
|||||||
service_id = launcher.get_id()
|
service_id = launcher.get_id()
|
||||||
# cut the .desktop suffix
|
# cut the .desktop suffix
|
||||||
service_id = service_id[:-8]
|
service_id = service_id[:-8]
|
||||||
|
try:
|
||||||
bus.start_service_by_name(service_id)
|
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