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

Re: /etc/profile and X



On 12 Jun 2003 David Fokkema <dfokkema@ileos.nl> wrote:

>> On Thu, Jun 12, 2003 at 09:35:47AM -0400, Matthew Weier O'Phinney wrote:
>>> -- David Fokkema <dfokkema@ileos.nl> wrote
>>> (on Thursday, 12 June 2003, 01:10 PM +0200):
>>> Yes, I searched through the archives and read some of the comments.
>>> However, they don't tell me exactly what's going on...
>>> 
>>> /etc/profile is read by a login shell, and not by starting an xterm. Of
>>> course, so far, so good... However, when I log in to X, doesn't
>>> xdm/kdm/gdm run a login shell which then starts xinit or something like
>>> that? Apparantly not, because if I export a variable from /etc/profile,
>>> I don't see it in X. What does xdm/kdm/gdm do then?
>>> 
>>> So, how do I set a variable like CUPS_SERVER=nebula so that it is set
>>> during a console login _and_ during an X login?
>> 
>> Not sure what shell you're using, but in bash, I do the following:
>> 
>> 1) In $HOME/.bashrc (this could be in the profile somewhere; I don't
>>    manage a large system), I set and export any environment variables I
>>    need in my login shell.
>> 
>> 2) In $HOME/.bash_profile, I have the following lines at the top of the
>>    file:
>>    # Get the aliases and functions
>>    if [ -f ~/.bashrc ]; then
>>        . ~/.bashrc
>>    fi
>> 
>> 3) In $HOME/.xsession (which is called by xdm, gdm, and kdm), I add the
>>    very same lines above at the top of that file, before any specific items
>>    needed for the xsession.
>> 
>> Doing the above means I only need to change one file when I want to
>> change my environment, and ensures that that environment is available
>> whenever and whereever I'm working (login shell, non-login shell, and X
>> session).
>
> Perhaps I should've been more specific (sorry, :-). What I'm wondering
> about is _why_ /etc/profile is not read during an X login ....

I do not really *know* .... the designers of the X Window System and the
graphical login managers *could* have decided to make the X server read
/etc/profile at the start of every X session, but apparently they have
deemed it more appropriate to leave it as an exercise for system
administrators to make that happen, if desired.

> .... and what file I need to edit to have a _system-wide_ variable
> declaration.

/etc/profile, IMO. Just make sure it is also read at the start of each X
session by inserting a line to source /etc/profile into /etc/Xsession or
into every user's .xsession.

AFAIK there is no file in which to set environment variables that then would
*automatically* be available in X sessions as well as in shells on virtual
consoles.

Ben

-- 

B.F.M. Kal
Anjelierstraat 1,   2014 TC Haarlem,  Netherlands
tel +31 23 5324909, benkal@euronet.nl



Reply to: