[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: X11: How to export an environment?



Abdul Latip <dullatip@angin.com> writes:

> In a shell, it is easy to change the environment by using
> "export". E.g. switching the "PRINTER" env.

(Correct terminology would be "setting an environment variable"; in
Bourne-style shells, this happens to be done via the 'export' command.)

> Is there a way to do that in X11? E.g. is there a way to
> print in "galeon", other than using the "lpr -P otherlp"  
> option?

You should be able to set environment variables in your .xsession
script, if you use that.  I don't know if gnome-session or the KDE
equivalent offer a good way to set environment variables across the
entire session.

One thing I find handy is to create a separate script that contains
just environment variable settings, and then source that script from
both my .xsession and my shell dotfiles (.zlogin for zsh).  Then my
xsession file looks something like this:

  #!/bin/sh
  set +m
  . $HOME/.variables
  xrdb -cpp m4 $HOME/.Xresources.m4
  openbox &
  SESSION_PID=$!
  epist &
  xwrits typetime=6:30 breaktime=1:00 mouse top &
  wmfire -f2 &
  wait $SESSION_PID

So I read in the environment variables early on, start my window
manager (openbox) and let that start up while I also start other
useful programs.  At the end we tell the shell running the xsession
process to wait for the window manager to exit.  More conventionally,
we might skip the SESSION_PID nonsense and end the script with 'exec
openbox', with essentially the same effect.

-- 
David Maze         dmaze@debian.org      http://people.debian.org/~dmaze/
"Theoretical politics is interesting.  Politicking should be illegal."
	-- Abra Mitchell



Reply to: