You are not logged in.

#1 2013-07-24 09:13:16

EvanPurkhiser
Member
From: Akron, Ohio
Registered: 2010-08-17
Posts: 225
Website

[Solved] systemd-user-session: Best way to pass global ENV vars?

Hey guys,

So when using the user-session@.service from the user-session-units what's the best / cleanest way to set global environment variables for that systemd --user instance (and thus, all programs spawned from it)?

What I'm talking about is /etc/profile and $HOME/.profile.

For example, I usally configure my XDG_CONFIG_HOME and XDG_CACHE_HOME in my ~/.profile. But since systemd --user is being started by systemd --session none of these environment variables are loaded.

The solution I've come up is to change the ExecStart in the user-session@.service file to something like this:

ExecStart=/usr/bin/sh -c "source /etc/profile; source $HOME/.config/bash/environment; exec /usr/lib/systemd/systemd --user"

I know I could use the `EnvironmentFile` option to load the environment variables from a file, but it's not as flexable as a bash script.

Am I thinking about this problem wrong? Is there a more "systemd --user"-y way of solving the problem?

Last edited by EvanPurkhiser (2013-08-12 03:02:48)

Offline

#2 2013-08-12 03:01:52

EvanPurkhiser
Member
From: Akron, Ohio
Registered: 2010-08-17
Posts: 225
Website

Re: [Solved] systemd-user-session: Best way to pass global ENV vars?

I've more or less solved this using my own user-session units. I still don't know if my method would really be considered the proper way or not though.

Last edited by EvanPurkhiser (2013-08-12 03:02:19)

Offline

Board footer

Powered by FluxBB