Login Shell/Profile: Stop the Madness
After much consternation I feel the need to vent about shell environment
initialization. With the default Debian installation, /etc/profile and
~/.bash_profile are not sourced in the X windows environment. Apparently
this is because at no time is a login shell created which is necessary to
trigger profile initialization.
Changing this behavior is relatively easy but of course knowing which
solution is correct requires some experimentation. When I first asked
about this there were basically 4 suggestions:
1) Start a login shell with the appropriate flags such as xterm -ls. It
suffices to say this is not an ideal solution for all night coding
sessions.
2) Source the profile from ~/.bashrc. Now none of the four scripts source
any of the others near as I can tell so to get the system-wide profile
*and* your local profile one would have to source both /etc/profile and
~/.bash_profile but I must admit I didn't fully explore this solution as
it smelled like a band-aid right from the start.
3) Change the default Xresources or create a personal ~/.Xresources to
make xterm and rxvt and whatever other terminal you wish to use to always
be logon shells:
*VT100*loginShell: true
*Rxvt*loginShell: true
This too seems like an odd solution as one might conceivably want a
non-login shell otherwise it would have been setup this way by default.
4) Create a executable ~/.xsesssion with the following:
#!/bin/bash --login
exec x-session-manager
Notice the --login is what does the trick. I suspect this is the most
correct suggestion. Subsequent shells launched from the session will not
be login shells but then I suspect that is the desired behavior because
the profile environment is inherited rather than reevaluated. That seems
much more natrual.
There is one problem with this solution however. The ~/.xsession will not
be executed unless the "Default System Session" is selected (at least from
GDM that is). If you explicitly select GNOME or KDE for instance,
~/.xsession is never executed. For me, I had to have a ~/.xsession with
the following:
#!/bin/bash --login
exec /usr/bin/wmaker
But I propose a better solution: create the login shell duing X
initialization so that the profile is sourced for all users. I think
that's what most users would expect. Certainly each of us cannot be
expected to go through everything I just did.
Mike
Reply to: