niri-session: import login environment without the deprecated systemd call
Browse files at this commit4adbf0039308cd0667f33e60e09ae480eca64056Parent: 12de51d1 changed file +22 -7
- resources/niri-session +22 -7
resources/niri-sessionmodified+22 -7
| @@ -33,14 +33,29 @@ if hash systemctl >/dev/null 2>&1; then | |||
| 33 | systemctl --user reset-failed | 33 | systemctl --user reset-failed |
| 34 | 34 | ||
| 35 | # Import the login manager environment. | 35 | # Import the login manager environment. |
| 36 | - systemctl --user import-environment | 36 | + # |
| 37 | - | 37 | + # We intentionally import *all* environment variables. |
| 38 | - # DBus activation environment is independent from systemd. While most of | 38 | + # It's unfortunately commonplace for distros to initialize |
| 39 | - # dbus-activated services are already using `SystemdService` directive, some | 39 | + # things with shell scripts and set environment variables. |
| 40 | - # still don't and thus we should set the dbus environment with a separate | 40 | + # |
| 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; then | 49 | if hash dbus-update-activation-environment 2>/dev/null; then |
| 43 | - dbus-update-activation-environment --all | 50 | + # 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 | fi | 59 | fi |
| 45 | 60 | ||
| 46 | # Start niri and wait for it to terminate. | 61 | # Start niri and wait for it to terminate. |