[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Configuration of IceWm for the OpenBSD 3.5
- To: misc_(_at_)_openbsd_(_dot_)_org
- Subject: Re: Configuration of IceWm for the OpenBSD 3.5
- From: Greg Wooledge <greg_(_at_)_wooledge_(_dot_)_org>
- Date: Fri, 8 Oct 2004 21:39:33 -0400
- Mail-followup-to: misc_(_at_)_openbsd_(_dot_)_org
Greg (runman_(_at_)_speedfactory_(_dot_)_net) wrote:
> I may be incorrect, but I think that the machine starts up, loads the
> kernel, goes through the rc scripts, setting the $PATH variable (inclusive
> of /usr/local/bin), then X starts up, then xdm, the login screen is
> displayed, X refers to .xsession in the ~ (or home) directory to start up
> the window manager, which then refers to .icewm (in my case).
You were half right: you're incorrect. ;-) (But you're pretty close.)
If you login on a text console, you get a login shell. This means
your shell (whatever's in /etc/passwd) is invoked with a "-" in front
of its name, which is an ancient hack going back to the 1970s. This
in turns causes the shell to behave differently than it normally does:
it reads files that are only to be read on logins. For ksh or bash,
this means /etc/profile first, and then ~/.bash_profile (for bash, if
it exists), or ~/.profile (otherwise).
A normal (non-login) bash shell reads ~/.bashrc instead of those files.
A normal (non-login) ksh reads whatever file is pointed to by the
environment variable $ENV. Many people set this to ~/.kshrc but that's
Logging in with sshd is just the same. You get a login shell.
XDM, however, is an entirely different animal. When you login that
way, you don't have a normal shell -- you have an X session instead.
XDM reads ~/.xsession (which is a shell script) if that file exists,
to determine what programs should be run. When ~/.xsession terminates,
your X session terminates, and you're logged out. The X server is
terminated, and XDM respawns a new one, and draws a login box.
This means that XDM logins do *not* read /etc/profile or ~/.profile or
~/.tcshrc or ~/.login or any other file that shells read. Those
dot-files are for shells, and specifially for shells that are running
on terminals -- people often put things like "stty" and "fortune" in
them, and those wouldn't work without a terminal.
If your ~/.profile is safe to run on non-terminals (either because you
don't have any terminal-using programs in it at all, or because you
protected any tty code with "if test -t 0" or equivalent), then you
can "dot in" ~/.profile from ~/.xsession in order to get your familiar
environment when you login with XDM. The same goes for /etc/profile
or whatever else you want to dot in. It's all under your control.
If you don't have a ~/.xsession file, then a system-wide default X
session is used instead. This will usually have some reasonable
default behavior, such as "run xrdb if the user has a ~/.Xdefaults
file, then run xterm &, then exec a window manager". I don't run
X on OpenBSD so I'm not sure what OpenBSD's default X session looks
When you open an xterm, you get a normal (non-login) shell in it.
This means it doesn't read /etc/profile and so on, unless you specified
the "-ls" option to xterm. If your shell is bash, then the shell you
get in an xterm will read ~/.bashrc (see the man page for your shell
if you don't know what behavior it exhibits).
So, here's what I recommend:
1) Put your environment variables ($PATH etc.) in ~/.profile.
2) Sanitize ~/.profile so that it doesn't barf if you run it without a
3) Dot in ~/.profile from ~/.xsession (and then run whatever other X
programs you want, including and ending with your window manager).
4) Put transient shell code like aliases, functions, "set -o vi", and
so on in ~/.bashrc (if you use bash; otherwise ~/.kshrc, but make
sure you export ENV=$HOME/.kshrc in ~/.profile in that case).
5) Dot in ~/.bashrc at the end of ~/.profile (if you use bash).
6) If you use csh, stop it. It's horrible. ;-)
Greg Wooledge | "Truth belongs to everybody."
greg_(_at_)_wooledge_(_dot_)_org | - The Red Hot Chili Peppers
Visit your host, monkey.org