forge
Explore
Log in

Don't you dare go Hollow

niri-session: import login environment without the deprecated systemd call

Browse files at this commit

4adbf0039308cd0667f33e60e09ae480eca64056Ruben HutterParent: 12de51d
Replace the bare `systemctl --user import-environment` with
`dbus-update-activation-environment --systemd --all`, which imports the
same login environment into the systemd user manager and D-Bus without
triggering the deprecation warning. The old call remains as a fallback
for systems without dbus tools.
resources/niri-sessionmodified+22 -7
@@ -33,14 +33,29 @@ if hash systemctl >/dev/null 2>&1; then
33 systemctl --user reset-failed33 systemctl --user reset-failed
34 34
35 # Import the login manager environment.35 # Import the login manager environment.
36- systemctl --user import-environment36+ #
37-37+ # We intentionally import *all* environment variables.
38- # DBus activation environment is independent from systemd. While most of38+ # It's unfortunately commonplace for distros to initialize
39- # dbus-activated services are already using `SystemdService` directive, some39+ # things with shell scripts and set environment variables.
40- # still don't and thus we should set the dbus environment with a separate40+ #
41- # command.41+ # For example, debuginfod is initialized this way, and sets the
42+ # $DEBUGINFOD_URLS environment variable. If we don't export it,
43+ # then programs started from a systemd service (e.g. from xdg-autostart)
44+ # will be unable to use debuginfod.
45+ #
46+ # We cannot possibly know and list all variables like this, so
47+ # we import all of them into the environment. This also covers
48+ # any variables the user may have customized, such as $PATH.
42 if hash dbus-update-activation-environment 2>/dev/null; then49 if hash dbus-update-activation-environment 2>/dev/null; then
43- dbus-update-activation-environment --all50+ # The `--systemd` flag also sets the variables for systemd user services,
51+ # so we don't need a separate `systemctl --user import-environment` call.
52+ #
53+ # (This also avoids the deprecation warning printed by
54+ # a blanket `systemctl --user import-environment` that
55+ # some people find very annoying.)
56+ dbus-update-activation-environment --systemd --all
57+ else
58+ systemctl --user import-environment
44 fi59 fi
45 60
46 # Start niri and wait for it to terminate.61 # Start niri and wait for it to terminate.