View previous topic :: View next topic |
Author |
Message |
lordofthemoose n00b
Joined: 10 Aug 2003 Posts: 11
|
Posted: Wed Aug 13, 2003 1:39 am Post subject: kdm, .xsession: How do you set an env variable? |
|
|
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 |
|
|
jackp n00b
Joined: 05 Jun 2002 Posts: 12
|
Posted: Wed Aug 13, 2003 4:56 am Post subject: |
|
|
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 |
|
|
jackp n00b
Joined: 05 Jun 2002 Posts: 12
|
Posted: Wed Aug 13, 2003 5:11 am Post subject: |
|
|
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 |
|
|
lordofthemoose n00b
Joined: 10 Aug 2003 Posts: 11
|
Posted: Wed Aug 13, 2003 7:21 pm Post subject: |
|
|
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 |
|
|
|
|
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
|
|