You are not logged in.
I have the following in ~/.config/.environment.d/zz-personal-env.conf:
EDITOR=nvim
PATH="${HOME}/.local/bin:${PATH}"
SSH_ASKPASS=/usr/bin/ksshaskpass
SSH_ASKPASS_REQUIRE=prefer
Running the systemd environment generator binary with debug output seems to generate correct output:
$ SYSTEMD_LOG_LEVEL=debug /usr/lib/systemd/user-environment-generators/30-systemd-environment-d-generator
Looking for environment.d files in (higher priority first):
/home/francis/.config/environment.d
/etc/environment.d
/run/environment.d
/usr/local/lib/environment.d
/usr/lib/environment.d
Reading /usr/lib/environment.d/99-environment.conf…
/usr/lib/environment.d/99-environment.conf:9: setting BROWSER=firefox
/usr/lib/environment.d/99-environment.conf:10: setting EDITOR=nano
Reading /home/francis/.config/environment.d/zz-personal-env.conf…
/home/francis/.config/environment.d/zz-personal-env.conf:2: setting EDITOR=nvim
/home/francis/.config/environment.d/zz-personal-env.conf:3: setting PATH=/home/francis/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
/home/francis/.config/environment.d/zz-personal-env.conf:4: setting SSH_ASKPASS=/usr/bin/ksshaskpass
/home/francis/.config/environment.d/zz-personal-env.conf:5: setting SSH_ASKPASS_REQUIRE=prefer
BROWSER=firefox
EDITOR=nvim
PATH=/home/francis/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
SSH_ASKPASS=/usr/bin/ksshaskpass
SSH_ASKPASS_REQUIRE=prefer
And yet when I reload systemd, the PATH isn't modified:
$ sudo systemctl daemon-reload; systemctl --user daemon-reload
$ systemctl --user show-environment | grep ^PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
What's going on here? Bug with systemd's environment generator? Something else is running after daemon-reload and resetting the PATH variable? My other variables are set correctly.
Last edited by auxym (2025-01-26 19:45:26)
Offline
user-environment-generators appear to be intended to setup things for systemd user services ,not the normal user environment .
The user environment is set by the shell a user starts, with settings taken from ~/.bash_profile or equivalent.
https://wiki.archlinux.org/title/Systemd/User#PATH has an example how to ensure systemd user services have the same PATH as the normal user environment .
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
Thanks for the info.
The issue I have with using shell config is that the variables are then specific to the shell and executables spawned by the shell. GUI apps for example wouldn't have access to those variables. Or do I misunderstand?
I can use the DE/DM to set variables, but then they wouldn't be available when logging in over ssh.
Is there an alternative that would then set the variables for everything?
Offline
/etc/profile or the local .{bash_,zsh_,fish_,whatever}profile should™ get parsed by most things.
Offline
Indeed, I was mistaken.
I have fish set as my login shell, and setting variables in config.fish (with
set -x
) seems to be inherited even in processes not spawned by fish. I guess either KDE or systemd imports the environment from the login shell somewhere in the startup/login process.
Thank you both for the clarifications.
Offline
environment variables are passed down to child processes, if you're logging in without a DM then the login shell will always be the parent of almost anything you're running under it.
Please mark as [SOLVED] by editing the title in your first post (might have to shorten a bit)
Last edited by V1del (2025-01-26 19:18:50)
Offline
Yeah, what I didn't know is that when logging in *with* a DM (KDE/SDDM), the environment still inherits my login shell's variables.
I marked the post as solved (sort of).
Offline