summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Franzmann2022-05-22 17:22:50 +0200
committerFlorian Franzmann2022-05-23 18:01:26 +0200
commitbbb55c387e4369afa4806a1f21a395b2837e3eaa (patch)
tree65520d1cd62d250f6835205c3a671cc2ff415651
parent3f75aab175cfd72c0d14eca19a1d1209b8d54c05 (diff)
utils/dbus: Add scripts for setting up user session
-rw-r--r--utils/dbus/HISTORY4
-rwxr-xr-xutils/dbus/INSTALL6
-rw-r--r--utils/dbus/Xsession.d/20dbus_xdg-runtime24
-rw-r--r--utils/dbus/Xsession.d/75dbus_dbus-launch22
-rw-r--r--utils/dbus/Xsession.d/95dbus_update-activation-env17
5 files changed, 72 insertions, 1 deletions
diff --git a/utils/dbus/HISTORY b/utils/dbus/HISTORY
index e0ec412f03..e1054b0418 100644
--- a/utils/dbus/HISTORY
+++ b/utils/dbus/HISTORY
@@ -1,3 +1,7 @@
+2022-05-21 Florian Franzmann <bwlf@bandrate.org>
+ * INSTALL, Xsession.d: install scripts from Debian for setting up the
+ user session
+
2022-05-17 Florian Franzmann <bwlf@bandrate.org>
* DEPENDS: add optional dependency on systemd
diff --git a/utils/dbus/INSTALL b/utils/dbus/INSTALL
index c1015a6d4f..cd8366116e 100755
--- a/utils/dbus/INSTALL
+++ b/utils/dbus/INSTALL
@@ -3,4 +3,8 @@ default_install &&
if is_depends_enabled $SPELL doxygen; then
mkdir -p "$INSTALL_ROOT/usr/share/doc/$SPELL" &&
cp -r "$SOURCE_DIRECTORY"/doc/api/* "$INSTALL_ROOT/usr/share/doc/$SPELL/"
-fi
+fi &&
+
+mkdir -p "$INSTALL_ROOT"/etc/X11/Xsession.d &&
+install -m644 -o root -g root "$SPELL_DIRECTORY"/Xsession.d/* \
+ "$INSTALL_ROOT"/etc/X11/Xsession.d/
diff --git a/utils/dbus/Xsession.d/20dbus_xdg-runtime b/utils/dbus/Xsession.d/20dbus_xdg-runtime
new file mode 100644
index 0000000000..c5417277d3
--- /dev/null
+++ b/utils/dbus/Xsession.d/20dbus_xdg-runtime
@@ -0,0 +1,24 @@
+# vim:set ft=sh sw=2 sts=2 et:
+
+if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && [ -n "$XDG_RUNTIME_DIR" ] && \
+ [ "$XDG_RUNTIME_DIR" = "/run/user/`id -u`" ] && \
+ [ -S "$XDG_RUNTIME_DIR/bus" ]; then
+ # We are under systemd-logind or something remarkably similar, and
+ # a user-session socket has already been set up.
+ #
+ # Be nice to non-libdbus, non-sd-bus implementations by using
+ # that as the session bus address in the environment. The check for
+ # XDG_RUNTIME_DIR = "/run/user/`id -u`" is because we know that
+ # form of the address, from systemd-logind, doesn't need escaping,
+ # whereas arbitrary addresses might.
+ DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
+ export DBUS_SESSION_BUS_ADDRESS
+fi
+
+if [ -x "/usr/bin/dbus-update-activation-environment" ]; then
+ # tell dbus-daemon --session (and systemd --user, if running)
+ # to put a minimal subset of the Xsession's environment in activated
+ # services' environments
+ dbus-update-activation-environment --verbose --systemd \
+ DBUS_SESSION_BUS_ADDRESS DISPLAY XAUTHORITY
+fi
diff --git a/utils/dbus/Xsession.d/75dbus_dbus-launch b/utils/dbus/Xsession.d/75dbus_dbus-launch
new file mode 100644
index 0000000000..fcac6f42c9
--- /dev/null
+++ b/utils/dbus/Xsession.d/75dbus_dbus-launch
@@ -0,0 +1,22 @@
+# $Id:$
+# In order to activate the session bus at X session launch
+# simply place use-session-dbus into your /etc/X11/Xsession.options file
+#
+
+STARTDBUS=
+DBUSLAUNCH=/usr/bin/dbus-launch
+
+if has_option use-session-dbus; then
+ if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && [ -x "$DBUSLAUNCH" ]; then
+ STARTDBUS=yes
+ fi
+fi
+
+if [ -n "$STARTDBUS" ]; then
+ # Note that anything that is D-Bus-activated between here and
+ # 95dbus_update-activation-env will not have the complete environment
+ # set up by Xsession.d, unless the Xsession.d snippet that sets the
+ # environment variable also calls dbus-update-activation-environment.
+ # See <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815503>
+ eval $($DBUSLAUNCH --exit-with-session --sh-syntax)
+fi
diff --git a/utils/dbus/Xsession.d/95dbus_update-activation-env b/utils/dbus/Xsession.d/95dbus_update-activation-env
new file mode 100644
index 0000000000..1626e74555
--- /dev/null
+++ b/utils/dbus/Xsession.d/95dbus_update-activation-env
@@ -0,0 +1,17 @@
+# vim:set ft=sh sw=2 sts=2 et:
+
+if [ -n "$DBUS_SESSION_BUS_ADDRESS" ] && \
+ [ -x "/usr/bin/dbus-update-activation-environment" ]; then
+ # subshell so we can unset environment variables
+ (
+ # unset login-session-specifics
+ unset XDG_SEAT
+ unset XDG_SESSION_ID
+ unset XDG_VTNR
+
+ # tell dbus-daemon --session (and systemd --user, if running)
+ # to put the Xsession's environment in activated services'
+ # environments
+ dbus-update-activation-environment --verbose --systemd --all
+ )
+fi