Setting environmental variables for all applications launched in a gnome session

Back in the days I used a tiling WM, I was able to set environmental variables for all applications via ~/.xinitrc or other methods. With Gnome, this method does not work and I need to use systemd’s environment.d, as explained here:

However, my use case is a bit different and according to environment.d(5) I can’t use it because it doesn’t support shell commands. I would like to have the following variables set globally for my Gnome session:

export MPD_HOST="$(secret-tool lookup mpd-host localhost)@localhost"
export GITHUB_TOKEN="$(secret-tool lookup github-namespace doronbehar)"

Putting these lines in ~/.gnomerc doesn’t work, see this thread. For most purposes, I currently have these lines in my ~/.profile so at least my shell knows these vars. However, I have many more such calls to secret-tool for other env vars and I’d like to set them only once, to reduce my shell startup time.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.