Web lists-archives.com

Re: The same environment variables everywhere




David Wright [2017-02-27 10:56:55-06] wrote:

>>     systemctl --user import-enviroment
>
> Is that typo actually in the file?

No. I just (mis)typed those "files" here. In practice they contain quite
a lot more than that.

>> ~/.xsession:
>> 
>>     . ~/.profile
>
> My profile has side effects. Calling it from ~/.xsession
> would repeat them, which would be undesirable.

I moved my variable assignments to ~/.environment.sh and source that to
~/.profile and ~/.xsession.

> Have you tried putting an EnvironmentFile= in here (man 5
> systemd.service)? You could source the file from elsewhere if required
> so that you only need one set of definitions.

(EnvironmentFile's primary description is in systemd.exec(5).)

Doesn't work well with services that need X session which sets DISPLAY,
XAUTHORITY, GPG_AGENT_INFO, SSH_AUTH_SOCK and maybe other things. Some
of them have no static values. So, it's simpler to have things like:

~/.xsession:

    . ~/.environment.sh     # Import my variables.

    systemctl --user import-environment
    systemctl --user start [service-that-needs-X-session-environment]
    my-window-manager
    systemctl --user stop [service-that-needs-X-session-environment]

-- 
/// Teemu Likonen   - .-..   <https://keybase.io/tlikonen> //
// PGP: 4E10 55DC 84E9 DFF6 13D7 8557 719D 69D3 2453 9450 ///

Attachment: signature.asc
Description: PGP signature