I have to set an environment variable called GDK_NATIVE_WINDOWS to fix the problem with Eclipse buttons in Ubuntu. To set the environment variable, I added the following line to ~/.pam_environment.

GDK_NATIVE_WINDOWS DEFAULT=true

Surprisingly, the environment variable doesn't get set when I echo $GDK_NATIVE_WINDOWS in a terminal. However, all other environment variables that I've listed in ~/.pam_environment are set properly. Besides, when I switch to a tty, e.g. Alt+Ctrl+F1, the environment variable gets set correctly. Can anyone tell what's wrong with setting this environment variable in ~/.pam_environment?

link|improve this question

57% accept rate
1  
did you restart your X session? – honk Apr 12 '10 at 17:24
Yes, I restarted my X session by logging out and in, and even restarting the machine. – reprogrammer Apr 14 '10 at 0:41
feedback

4 Answers

I think that's because when you start a terminal you are not launching a login session. it's a terminal session, and it works with different rules. I never really got the difference and the need to differentiate, but in any case I suggest you to use ~/.bash_profile and/or ~/.bashrc to achieve the same result, unless you have been suggested to use pam for specific reasons.

link|improve this answer
It's recommended to use .pam_environment not shell scripts. See help.ubuntu.com/community/EnvironmentVariables – reprogrammer Apr 14 '10 at 0:47
feedback

You have a space in between GDK_NATIVE_WINDOWS and DEFAULT=true . This differs from the example you linked.

Try:

GDK_NATIVE_WINDOWS=true

link|improve this answer
1  
pam_env doesn't use shell syntax. linux.die.net/man/5/pam_env.conf – Ignacio Vazquez-Abrams Apr 12 '10 at 21:53
Corrected, thanks. – kmarsh Apr 13 '10 at 12:10
feedback

As you have identified, your environment variables should be set in ~/.pam_environment as recommended on https://help.ubuntu.com/community/EnvironmentVariables. Easier said than done ;)

It is possible that you ran into the same configuration gap that existed for me. See the workaround for encrypted home below.

My ~/.pam_environment:

PATH            DEFAULT=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:${HOME}/bin
IDEA_JDK        DEFAULT=${HOME}/Applications/jdk

Why the ugly static path? ${PATH} would not work for me. I bricked my login several times trying to work around it so I am sticking with the ugly static copy of the defaults :)

Workaround for Encrypted Home Folders

In Ubuntu releases up to and including Precise 12.04 Beta 2, if you are using an encrypted home directory you will need to modify /etc/pam.d/common-session to get it to load ~/.pam_environment. This solution apparently works for earlier releases, but I have not tested it.

Guenther Montag (g-montag) wrote on 2010-08-19:

This seems to be an issue with encrypted home directories. I added

session required pam_env.so

at the end of /etc/pam.d/common-session and now ~/.pam_environment gets read. On another system without encrypted home directories (also 10.04) the work around is not needed. Perhaps in my case the system tries to read ~/.pam_environment before it is decrypted.

link|improve this answer
My home folder is not encrypted. – reprogrammer Apr 5 at 4:26
feedback
up vote 0 down vote accepted

It looks like it's just a bug that my environment variable is not being set.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.