core-agent-linux/qubesagent/xdg.py
Marek Marczykowski-Górecki 4a7c668549
Move 'qubesxdg' into qubesagent python package
Since we have proper python package, use it instead of hacky one-file
package. This will ease installation and packaging, including switching
to python3.
2018-04-02 23:19:01 +02:00

28 lines
808 B
Python
Executable File

#!/usr/bin/python
from gi.repository import Gio
import sys
def launch(desktop, *files):
launcher = Gio.DesktopAppInfo.new_from_filename(desktop)
try:
import dbus
if hasattr(launcher, 'get_boolean'):
activatable = launcher.get_boolean('DBusActivatable')
if activatable:
bus = dbus.SessionBus()
service_id = launcher.get_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)
if __name__ == "__main__":
launch(*sys.argv[1:])