From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim X Newsgroups: gmane.emacs.help Subject: Re: "source" shell commands Date: Mon, 26 Mar 2007 21:30:45 +1000 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <87648ofdi2.fsf@lion.rapttech.com.au> References: <87bqii936r.fsf@baldur.tsdh.de> <85wt16btg5.fsf@lola.goethe.zz> <46059643.8090705@gatech.edu> <4605BD72.6040904@gatech.edu> <2D4FA764-9DEE-4F5C-8501-AA4E3F4787A7@Web.DE> <46065528.5000702@gatech.edu> <87aby1eyri.fsf@lion.rapttech.com.au> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1174909162 27735 80.91.229.12 (26 Mar 2007 11:39:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 26 Mar 2007 11:39:22 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Mar 26 13:39:15 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HVnXe-0004zi-UY for geh-help-gnu-emacs@m.gmane.org; Mon, 26 Mar 2007 13:39:15 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HVnZt-0000wy-B8 for geh-help-gnu-emacs@m.gmane.org; Mon, 26 Mar 2007 06:41:33 -0500 Original-Path: shelby.stanford.edu!newshub.stanford.edu!news.kjsl.com!news.glorb.com!newspeer.tds.net!216.168.1.162.MISMATCH!sn-xt-sjc-02!sn-xt-sjc-11!sn-xt-sjc-09!sn-post-sjc-01!supernews.com!corp.supernews.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.95 (gnu/linux) Cancel-Lock: sha1:vALC6OXn2OmF6dlCLpVegqU2drQ= Original-X-Complaints-To: abuse@supernews.com Original-Lines: 87 Original-Xref: shelby.stanford.edu gnu.emacs.help:146599 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:42203 Archived-At: Matthew Flaschen 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