-   Linux - Newbie (
-   -   Exporting a variable from within .xsession (

mike11 03-31-2011 06:31 AM

Exporting a variable from within .xsession
Hi All,

I'm trying to export a variable from within the .xsession so it will be available to any application started afterwards.

Here is a minimial .xsession file:

export MYVAR=123
exec gnome-session

The problem is that when I start a terminal and do:

echo $MYVAR
I get an empty string, meaning it's undefined.


David the H. 03-31-2011 06:58 AM

Your shell doesn't read the .xsession file, which I believe is only for the gui environment. You'll have to set the variable separately in your bashrc or whatever you use.

For bash, see the INVOCATION section of the man page for which files it reads.

mike11 03-31-2011 07:48 PM

Thanks. I'm not sure this is related to the shell (bash or something else). Basically what I want is to export a variable from within .xsession so it will be available, let's call it globally, to every application started afterwards.

All times are GMT -5. The time now is 08:20 PM.