Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
kdm, .xsession: How do you set an env variable?
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
lordofthemoose
n00b
n00b


Joined: 10 Aug 2003
Posts: 11

PostPosted: Wed Aug 13, 2003 1:39 am    Post subject: kdm, .xsession: How do you set an env variable? Reply with quote

Hi
My problem is the following:
I'd like to set an environment variable (add something to my $PATH, in particular) when my session starts (I use KDE with kdm)
I read in other posts that I had to create a .xsession file that would be executed .
I therefore put something like
#!/bin/sh
export PATH=$PATH:my/new/path in it, then chmod +x .xsession

It didn't work. I symlinked it to a .xinitrc (just in case), did not work either.
I made sure it was executed: in /etc/X11/Sessions/kde-xxx I added a line like
$HOME/.xsession, with no effect.

How can I set this environment variable when kde starts (or before)?

Thanks in advance.
Back to top
View user's profile Send private message
jackp
n00b
n00b


Joined: 05 Jun 2002
Posts: 12

PostPosted: Wed Aug 13, 2003 4:56 am    Post subject: Reply with quote

try leaving out the #!/bin/sh in your ~/.xsession file. And since PATH is already an exported variable, you can leave out the export and have it just read:

PATH=$PATH:/new/directory

then, in /etc/X11/Sessions/kde-xxx, make sure you put

source $HOME/.xsession

OR...since you're modifying the kde sessions file anyway, you might want to try to append the PATH variable in the kde-xxx file instead, see if that works.
Back to top
View user's profile Send private message
jackp
n00b
n00b


Joined: 05 Jun 2002
Posts: 12

PostPosted: Wed Aug 13, 2003 5:11 am    Post subject: Reply with quote

hmm....in theory, what I just told you would work, except I just tried it and it didn't.

After investigating a little further, it seems as loading up an xterm then echo'ing $PATH doesn't show the directory i added. Found out that's because xterm loads bash, which sources .bashrc, which in turn sources /etc/profile, which in turn sources /etc/profile.env--that file contains the very first PATH declaration, like so:

export PATH='blahblah:bunch:of:directories'

and all of this happens way after your .xsession is loaded, so that directory that you had appended got lost.

One thing that could work is that you export another variable in your .xsession or kde-xxx file, then append to the path in your .bashrc.

in .xsession or kde-xxx:
Code:

export APPENDPATH=/new/directory


then in .bashrc:
Code:

PATH=$PATH:$APPENDPATH


Hope that helps
Back to top
View user's profile Send private message
lordofthemoose
n00b
n00b


Joined: 10 Aug 2003
Posts: 11

PostPosted: Wed Aug 13, 2003 7:21 pm    Post subject: Reply with quote

Thanks a lot, I finally exported things from my .bashrc and (almost) everything's fine.
However, this only works after you've opened an xterm, doesn't it (and it is permanent) ?
I mean: suppose I start KDE, then select "run command", type "xxyy" which is in my path ~/bin that I wanted to add, then KDE won't find it. That's why I wanted my path to be set right at the beginning.
Do you have any ideas?
Thanks again
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum