From c22dcdfe065f2db63e1b8c5e8a9a4de9f9e6bb34 Mon Sep 17 00:00:00 2001 From: Pratham Patel Date: Thu, 22 May 2025 13:30:53 +0530 Subject: [PATCH] use `dbus-update-activation-environment` to update/initialize environment variables The goal is to update the environment variables for the user's systemd session **and** the services listening on user's d-bus session. Until now, the variables were updated using the `import-environment` environment command of `systemctl`. But, it would only be executed if systemd was present on the host system. Leaving the variables on the d-bus side either uninitialized or with incorrect values. Therefore, instead of using `systemctl`, use the `dbus-update-activation-environment` command to initialize/update the environment variables for user's d-bus session but also for user's systemd session. This is done by passing the `--systemd` option. When systemd is not detected, the command doesn't fail, it simply doesn't update the variables for user's systemd session. And since a systemd user session doesn't exist, no harm no foul. --- data/start-cosmic | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/start-cosmic b/data/start-cosmic index 7e8ccbb..4f6c80a 100755 --- a/data/start-cosmic +++ b/data/start-cosmic @@ -38,9 +38,9 @@ export QT_AUTO_SCREEN_SCALE_FACTOR=1 export QT_ENABLE_HIGHDPI_SCALING=1 export DCONF_PROFILE=cosmic -if command -v systemctl >/dev/null; then +if command -v dbus-update-activation-environment >/dev/null; then # set environment variables for new units started by user service manager - systemctl --user import-environment XDG_SESSION_TYPE XDG_CURRENT_DESKTOP DCONF_PROFILE + dbus-update-activation-environment --systemd XDG_SESSION_TYPE XDG_CURRENT_DESKTOP DCONF_PROFILE fi # Run cosmic-session if [[ -z "${DBUS_SESSION_BUS_ADDRESS}" ]]; then