Session's environment variables
Related materials
As I can confirm after multiple failures, according to “How do I set an environmental variable for a GNOME session? (superuser.com)”, setting environment variables in a session is tricky, as there are multiple candidate places for this.
I had a look at “How do xsession, xinitrc and .i3/config play together?”, which is very valuable, but did not help.
Practical case
For the practical case, I need to properly set an SSH_AUTH_SOCK
environment variable (which is set, except not with the expected value, by another process).
From a command line, I can do this, which gives me what I expect.
export $(gnome-keyring-daemon --start --components=ssh)
I tried this in ~/.config/i3/config
:
exec --no-startup-id eval $(gnome-keyring-daemon --start --components=ssh)
exec --no-startup-id export $(gnome-keyring-daemon -s)
I tried this in ~/.profile
:
if [ "$0" = "/etc/gdm/Xsession" ]; then
eval $(gnome-keyring-daemon --start --components=ssh)
export $(gnome-keyring-daemon -s)
fi
I tried this in a ~/.xsession
:
eval $(gnome-keyring-daemon --start --components=ssh)
export $(gnome-keyring-daemon -s)
None works.
Question
Seems one can't set and export an environment variable from i3's config
. If I'm wrong, what was wrong in my config
? If I'm not wrong, what's the best practice to define environment variables for an i3 session?
Notes (update 1)
At least ~/.xsession
does not seems to be sourced for me, running Ubnuntu 12.04, which uses LightDM for the login screen. Prior Ubuntu version used GDM and there are complaints on the web about GDM ignoring ~/.xsession
too.
-edit- Wanted to link to https://faq.i3wm.org/question/18/how-do-xsession-xinitrc-and-i3config-play-together/ but that link is already in the question.