all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tim X <timx@nospam.dev.null>
To: help-gnu-emacs@gnu.org
Subject: Re: "source" shell commands
Date: Mon, 26 Mar 2007 21:30:45 +1000	[thread overview]
Message-ID: <87648ofdi2.fsf@lion.rapttech.com.au> (raw)
In-Reply-To: mailman.1432.1174870550.7795.help-gnu-emacs@gnu.org

Matthew Flaschen <matthew.flaschen@gatech.edu> writes:

> Tim X wrote:
>> The simplest solution I've found is to change the Xsession script that sets up
>> your session to be a bash login shell - then ~/.bash_profiel (or ~/.profile)
>> will get sourced prior to the window manager being started and everything that
>> is then spawned by the window manager (using menus, 'run' boxes or start icons)
>> will inherit the users login env. 
>
> I'm sorry.  I don't understand what you mean here.  Exactly what would I
> have to modify to do this?
>

Its difficult to be precise as things differ depending on the setup you have
and the display manager you are using. However, essentially, xdm and gdm, two
of the main display managers, have a script called (usually) Xsession. On many
systems, including Debian (and I therefore suspect Ubuntu) this script is not
run as a login script and is normally a /bin/sh script rather than /bin/bash. 

As it is not run as a login script, it doesn't source your ~/.profile (or
~/.bash_profile. This script also usually sources the client startup scripts
(either the system default ones or a 'customized' one which is usuallyy called
~/.Xsession or ~/.xsession. Under debian, if you have a .Xsession script, that
will be executed instead of the system defaults. (What determines exactly what
is executed is usually selected from a menu on the display manager login
screen. Common entries are "Failsafe", "Default", "Gnome", "Last Session" etc). 

Usually the last entry in the client script sourced by the system Xsession
script is something like

exec window_manager

which means the window manager process inherits the process the Xsession script
was running in. Once the window manager process exits, your X session exits and
control returns to the display manager. 

If the Xsession script is not running as a login shell and it has not sourced
your environment settings in ~/.profile (or whatever), none of these settings
are in effect for the window manager or any processes it spawns (such as when
you start an aplication from a menu). To fix this problem, you need to have
your .profile sourced *before* the window manager starts. The easiest way to do
this is to change the Xsession script to run as a login shell. On Debian, this
can easily be achieved by changing the first line from

/bin/sh

to

/bin/bash --login

The script will then source yor startup files before it starts executing and
the window manager will inherit this environment. As environment variables are
exported to sub shells, etc, anything that is started from within the window
manager will inherit all of these environment variables. 

As mentioned in an earlier post, my system is heavily customized, so I'm
working from memory a bit regarding exactly which file to change. It also
depends on the display manager and I'm not familiar with KDE, so I can't be
precise as to exactly which file it would be, but the basic principle is the
same - find the script that sources the session setup scripts and/or runs the
window manager and make it a login shell rather than just a normal shell. 

For xdm I think the file is in /etc/X11/xdm/Xsession and for gdm I think the
file is /etc/gdm/Xsession. (Note that Debian also has an /etc/X11/Xsession and
an /etc/X11/Xsession.d directory of files. These are *not* the ones you need to
change. 

HTH

Tim

P.S. Years ago, when I first started using X windows (late 80s), things were
somewhat simpler. The user would have an .Xsession file that contained all the
startup stuff they wanted done and then do an exec at the end to start the wm.
Then things changed to make it easier to maintain a default setup rather than
require the user to manage it. At this time, the default was to run things as a
login shell. This later changed and I've never really found out why. There is
probably a god reason and possibly there are some issues with doing this, but
I've never had a problem in 20 years (maybe I'm just lucky). 

PPS Another thing you could try which may work is if your system has a
/etc/X11/Xsession.d directory, you could try dropping a new file in there which
just sources the user's ~/.bash_profile or ~/.profile. While this may work
fine on a single user box, it could cause issues on a multi-user system as not
everyone runs bash as their login shell. 
-- 
tcross (at) rapttech dot com dot au

  parent reply	other threads:[~2007-03-26 11:30 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1360.1174733204.7795.help-gnu-emacs@gnu.org>
2007-03-24 13:33 ` "source" shell commands Tassilo Horn
2007-03-24 14:35   ` David Kastrup
2007-03-24 15:24     ` Barry Margolin
2007-03-24 21:21       ` Matthew Flaschen
2007-03-25  0:08         ` Matthew Flaschen
2007-03-25 10:33           ` Peter Dyballa
2007-03-25 10:55             ` Matthew Flaschen
2007-03-25 11:53               ` Peter Dyballa
2007-03-26  0:44                 ` Matthew Flaschen
2007-03-26  8:16                   ` Peter Dyballa
2007-03-26  9:59                     ` Matthew Flaschen
     [not found]               ` <mailman.1412.1174823876.7795.help-gnu-emacs@gnu.org>
2007-03-25 22:36                 ` Tim X
2007-03-26  0:53                   ` Matthew Flaschen
     [not found]                   ` <mailman.1432.1174870550.7795.help-gnu-emacs@gnu.org>
2007-03-26 11:30                     ` Tim X [this message]
     [not found]       ` <mailman.1381.1174771402.7795.help-gnu-emacs@gnu.org>
2007-03-25  2:46         ` Tim X
2007-03-25  4:03           ` Matthew Flaschen
     [not found]           ` <mailman.1397.1174795525.7795.help-gnu-emacs@gnu.org>
2007-03-25 10:56             ` Tim X
2007-03-26  8:13             ` Tassilo Horn
2007-03-26  8:57               ` Matthew Flaschen
     [not found]               ` <mailman.1436.1174899596.7795.help-gnu-emacs@gnu.org>
2007-03-26  9:08                 ` Tassilo Horn
2007-03-26  9:55                   ` Matthew Flaschen
2007-03-25  2:32 ` Tim X
2007-03-25  2:59   ` Matthew Flaschen
2007-03-24 10:44 Matthew Flaschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87648ofdi2.fsf@lion.rapttech.com.au \
    --to=timx@nospam.dev.null \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.