Click to See Complete Forum and Search --> : Setting environment variables at startup


o0zi
01-21-2004, 05:00 PM
How do I go about setting an environment variable in a startup script, so that every application I run in X notices that variable? I could put a dot before I run the script, but that would run from within another script, so I'd have to put a dot before that as well... surely there's an easier way?

evac-q8r
01-21-2004, 05:30 PM
~/.bashrc (if you're using bash)

EVAC

ph34r
01-21-2004, 05:37 PM
or in /etc/profile

bwkaz
01-21-2004, 08:42 PM
~/.xinitrc or /etc/X11/xinit/xinitrc

(If you have the first one, set it there -- if not, set it in the second one. Also, if you boot directly to X, you'll need to change a file named .xsession or Xsession or something like that instead.)

Otherwise, since X cleans its environment on startup, and you can start programs from your window manager menu without starting a shell, the changes to /etc/profile or ~/.bashrc won't always actually take effect. Your window manager is started from your xinitrc file, so setting the variable in there will set it in your window manager's environment, and also the environment of any program that your WM starts.