Running X sessions and setting the environment

Since the long ago time when I used both XWindows and Linux console using getty program, I’ve setup some files this way:

source ~/.bashrc
source ~/.bash_common
source ~/.bash_common
numlockx on
exec gnome-session

In ~/.bash_common I’ve put export Bash statements to set environment variables I use both in console sessions and in XWindows.

In ~/.bashrc I’ve put Bash alias statements, Bash function definitions and other setting specific to Bash used interactively, such as PROMPT_COMMAND shell variable or

shopt -sq cdspell checkwinsize lithist extglob checkhash histappend mailwarn histverify histreedit

In this sophisticated way my environment initializes both if I login from the console to Bash or start my session in some other way, while the initialization specific to Bash runs only when I start Bash as an interactive shell (e.g. from getty or in an X terminal such as Gnome Terminal or Konsole, that is Bash started with -i flag).

This improves performance as when Bash starts non-interactively, settings from ~/.bashrc are not unnecessarily read.

Finally my ~/.xsession file runs Gnome Session with all variables I’ve set in ~/.bash_common.

That more, that good.

But there is a problem I don’t know how to solve: When logging in with GDM display manager if I specify an alternate desktop environment than System Default (which apparently runs my ~/.xsession) I get it started without variables in ~/.bashrc. And I don’t know how to make it work.

A reader, do you know how to work around this problem?

Not a big trouble for me however, because now I use exclusively Gnome 3.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.