Index: tlmisc/profiles/tl-run-profile =================================================================== --- tlmisc/profiles/tl-run-profile (revision 33472) +++ tlmisc/profiles/tl-run-profile (working copy) @@ -1,7 +1,7 @@ #!/usr/bin/env python-thinlinc # -*- mode: python; coding: utf-8 -*- # -# Copyright 2014 Cendio AB. +# Copyright 2014-2018 Cendio AB. # For more information, see http://www.cendio.com import sys @@ -8,6 +8,7 @@ import os import pipes import re +import subprocess # Add modules dirs. FIXME: Use relative paths. sys.path = ["/opt/thinlinc/modules"] + sys.path @@ -33,6 +34,18 @@ escaped_argv.append(pipes.quote(arg)) return " ".join(escaped_argv) +def update_dbus_environ(environ): + if which.which("dbus-update-activation-environment") is None: + return + + print 'Updating D-Bus and systemd environment...' + p = subprocess.Popen(["dbus-update-activation-environment", + "--systemd", "--all"], + env=environ) + p.wait() + if p.returncode != 0: + print >>sys.stderr, "tl-run-profile: Failed to update D-Bus and systemd environment" + if __name__ == "__main__": if len(sys.argv) != 1: print >>sys.stderr, "Usage:" @@ -46,6 +59,7 @@ if not os.getenv("TLCOMMAND").strip(): print >>sys.stderr, "tl-run-profile: Ignoring existing but empty TLCOMMAND." else: + update_dbus_environ(os.environ.copy()) print "Executing start program command: %s" % os.environ["TLCOMMAND"] sys.stdout.flush() try: @@ -152,6 +166,8 @@ break + update_dbus_environ(environ) + if (cmdline is not None) and (cmdline != ""): # Explicit command line print 'Executing profile command: %s' % cmdline Index: tlmisc/scripts/tl-dbus-launch.sh =================================================================== --- tlmisc/scripts/tl-dbus-launch.sh (revision 33472) +++ tlmisc/scripts/tl-dbus-launch.sh (working copy) @@ -9,5 +9,13 @@ # Start DBUS, if not already started if type dbus-launch > /dev/null 2>&1 && test -z "${DBUS_SESSION_BUS_ADDRESS}" ; then + echo "Starting new session D-Bus server..." eval `dbus-launch --sh-syntax --exit-with-session` +else + echo "Existing session D-Bus server found" fi + +if type dbus-update-activation-environment > /dev/null 2>&1 ; then + echo "Setting initial D-Bus and systemd environment..." + dbus-update-activation-environment --systemd DISPLAY XAUTHORITY +fi