How do I set an environment variable in a Unity session?
The easy way to set personal environment variables for Unity (or any other X session) is to add them to the file $HOME/.xsessionrc
. These variables are seen by everything launched in the session, via menus, GUIs, terminal windows, etc. For example, put this text in $HOME/.xsessionrc
:
# File sourced by /etc/X11/Xsession, for setting environment variables, etc.
export FOOVAR=testing
Log out and back in, then from a shell window:
my-pc> echo $FOOVAR
testing
Tested under 12.04, using Unity. But this feature is implemented by the /etc/X11/Xsession
script used by many types of desktop session, so it should work with any session type. See the Xsession
man page.
Create a file in /etc/X11/Xsession.d/
for it, e.g. /etc/X11/Xsession.d/98local
(it has to be executed before 99x11-common_start
).
If this doesn't work try to find out where the variable gets set. Something like
sudo grep -r IBUS_ENABLE_SYNC_MODE /etc/
may help here to find the file.