You are not logged in.
Hello guys,
the "user level" environment vars on my system are basically defined on two places:
* shell config file (i.e. config.fish): this is where the bulk of it resides, especially XDG-related stuff.
* ~/.config/environment.d/envvars.conf: specific to sway and systemd user units
I started to have a feeling that `envvars.conf` was a better place for these variables, so what is your take on moving all I can to `envvars.conf`? I know it's not common practice, but is it silly?
I know things like commands such as `set -gx SSH_AUTH_SOCK (gpgconf --list-dirs agent-ssh-socket)` is not supported. Also, I have to find a way (please help
) to import these vars back to shell.
Have a nice day
Offline
Environment variables are not global variables. Don't try to treat them as such.
Set environment variables in the environment where you want to use them. It's as simple as that.
~/.config/environment.d/ is the proper place to set variables you want to be available to systemd user services for your user only. /etc/systemd/user.conf is the propler place for those you want available to all user services. There are other places for variables you want available to all systemd services. And if you want a variable available to just a single service, it goes in the service file.
Then of course if you want a variable available to the interactive shell session, you put it in the rc/conf file for your interactive shell or your shell profile.
I started to have a feeling that `envvars.conf` was a better place for these variables
Only for the ones that are mean't to be there.
I know things like commands such as `set -gx SSH_AUTH_SOCK (gpgconf --list-dirs agent-ssh-socket)` is not supported. Also, I have to find a way (please help
) to import these vars back to shell.
I'm not sure what you mean by "not supported", but yes, anything needed in an interactive shell is of no use in the system.d user environment. You could source ~/.config/environment.d/*.conf from your shellrc file if you really wanted - it'd be harmless and acheive your goals - but that seems pretty ugly to me.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thanks for replying Trilby, your writing is very reasonable to me.
Besides the nice explanation, I understand you do think it is silly (and also ugly
) moving vars from shell config to environment.d and importing them back.
I don't feel like doing such move anymore, and maybe my user environment vars placement are already on the correct path.
I have a question though, I must have $GNUPGHOME set for both, shell and systemd so by now I have it set on `config.fish` and `envvars.conf`. Is this OK or a redundancy?
Offline
Good point. You could use `systemctl --user import-environment` optionally with that variable name in your profile, e.g.
#shell variables
MANPAGER=whatever
EDITOR=vim
#shell and systemd user session variables
GNUPGHOME=whatever
ANOTHERSHARED=thing
systemctl --user import-environment GNUPGHOME ANOTHERSHARED"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
You could use ~/.pam_environment to define environment variables that need to exist for all sessions (including the systemd --user environment).
e.g. PATH, or XDG_*
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
@eschwartz, that would definitely be my first go if I were not so committed to keep all config files under XDG specification. Thanks for pointing that out.
@Trillby, you nailed it, thanks again pal.
Offline
@eschwartz, that would definitely be my first go if I were not so committed to keep all config files under XDG specification. Thanks for pointing that out.
That does of course leave open the question of what you first use to set up XDG, since whatever that is cannot be something that requires XDG in order to find it. ![]()
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
Well that's easy:
export XDG_OUROBOROS=$XDG_OUROBOROS"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
xand wrote:@eschwartz, that would definitely be my first go if I were not so committed to keep all config files under XDG specification. Thanks for pointing that out.
That does of course leave open the question of what you first use to set up XDG, since whatever that is cannot be something that requires XDG in order to find it.
haha, yeah XDG seem like a "chicken/egg" problem so I chose "fish" to deal with it.
Offline