You are not logged in.

#1 2020-04-10 15:04:54

shadowfirebird
Member
From: Manchester, UK
Registered: 2015-10-25
Posts: 9

GUI Login is not a Bash login session? [SOLVED]

Okay, there are a whole bunch of different ways I could get around this.  And maybe I'm going slightly nuts worrying about it?  But if someone can tell me why this is happening, I'd really appreciate it.

Short version:  Fresh Helium install.  When I open a terminal, /etc/profile has not been run.  Only /etc/bash.bashrc.  If I log in remotely or from a non-GUI session, then it has been. 

I would really like the GUI login to behave the same as a remote login, because I don't want to have to change my $PATH in multiple places, which will eventually bite me on the arse.

Long version:
I wanted to change $PATH.  For anyone that ever logs into my computer and any process that might be running.  (In fact I'm adding `/snap/bin`.) 

So like a smartarse old UNIX-head I edited /etc/profile; and it didn't work.  (In fact, installing Snap adds `/etc/profile.d/apps-bin-path.sh`, so I didn't have to do that.  But I didn't know, because that didn't work either.

If I `bash -l` it works.  If I log in remotely, it works.  If I log in non-GUI (ctrl-alt-F1, etc) then it works.  It only doesn't work if I log in via lightDM. 

I'm forced to conclude that when LightDM starts a session for a user it starts a non-interactive, non-login session.  Because that would not call /etc/profile, just /etc/bash.bashrc.

Why?  More to the point, if I manage to change this (say, by calling /etc/profile from /etc/bash.bashrc), what will I break?

UPDATE:

I have found evidence of an ancient argument about this on the interwebs.  Apparently this is a wontfix by the lightDM maintainer?  Because he thinks logging in with LightDM doesn't count as logging in?  Or something.  See here.  And here

Not sure what has happened since but it seems as if that first link might have something:

/etc/gdm/Xsession had this code:
  # First read /etc/profile and .profile
  test -f /etc/profile && . /etc/profile
  test -f "$HOME/.profile" && . "$HOME/.profile"
  # Second read /etc/xprofile and .xprofile for X specific setup
  test -f /etc/xprofile && . /etc/xprofile
  test -f "$HOME/.xprofile" && . "$HOME/.xprofile"
so that, for example, ~/bin gets added to the path (by the default ~/.profile), and any user-customized environment setup gets run.

After switching from gdm to lightdm, this no longer happens. This is going to be a regression now that lightdm is becoming the default display manager.

I'm going to try putting that back in and see what happens...

...that appears to work.  Calling it solved.

Last edited by shadowfirebird (2020-04-10 20:51:35)

Offline

#2 2020-04-10 15:28:14

damo
....moderator....
Registered: 2015-08-20
Posts: 5,982

Re: GUI Login is not a Bash login session? [SOLVED]

If you login with lightdm, then ~/.bashrc is used. If you log in without a gui then ~/.profile is used.

So log in without lightdm and use startx etc?


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Online

#3 2020-04-10 15:44:59

shadowfirebird
Member
From: Manchester, UK
Registered: 2015-10-25
Posts: 9

Re: GUI Login is not a Bash login session? [SOLVED]

damo wrote:

So log in without lightdm and use startx etc?

That seems ... rather extreme.  It wouldn't just be me doing that but anyone else who used this computer, and the rest of the family are less Linux-head than I am by quite a wide margin.  "Look! The Pretty Graphical Environment! Which you can't use without Editing This File!"  Imagine the scorn.

Surely there must be some way around this other than "don't use the pretty thing which you can't replace with an equivalent"?

Any idea what Bad Thing Would happen if I just sourced /etc/profile from within /etc/bash.bashrc? 

Also: can you tell me where it's getting the path it does set from?  Not from /etc/bash.bashrc or from .bashrc, as far as I can tell?  (Maybe I can live with setting the PATH twice.)

Offline

#4 2020-04-10 16:46:53

damo
....moderator....
Registered: 2015-08-20
Posts: 5,982

Re: GUI Login is not a Bash login session? [SOLVED]

https://wiki.archlinux.org/index.php/LightDM

wiki wrote:

Environment variables

The script checks and sources /etc/profile, ~/.profile, /etc/xprofile and ~/.xprofile, in that order. If you are using a shell that does not source any of these files, you can create an ~/.xprofile to do so.


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Online

#5 2020-04-10 17:16:37

shadowfirebird
Member
From: Manchester, UK
Registered: 2015-10-25
Posts: 9

Re: GUI Login is not a Bash login session? [SOLVED]

damo wrote:

https://wiki.archlinux.org/index.php/LightDM

wiki wrote:

Environment variables

The script checks and sources /etc/profile, ~/.profile, /etc/xprofile and ~/.xprofile, in that order. If you are using a shell that does not source any of these files, you can create an ~/.xprofile to do so.

That script -- /etc/lightdm/Xsessions.conf -- does not appear in Bunsen.  Which sounds as if it might be the problem.

I have in the meantime found a 10-year-old flame war which appears to be about this very issue (!).  I'll edit my original post to include links, and maybe a solution.

Offline

#6 2020-04-10 17:29:46

damo
....moderator....
Registered: 2015-08-20
Posts: 5,982

Re: GUI Login is not a Bash login session? [SOLVED]

I posted the Arch link because their wiki is much better than the Debian one. Have you checked out https://wiki.debian.org/LightDM?

wiki wrote:

User configuration

LightDM itself has no user configuration. Once you've authenticated with your username and password, LightDM will run an X session. If you wish to configure your login environment, you must use the configuration files for whichever type of X session your system is configured to use. By default, this will be the Debian Xsession.

So it seems that you will need to configure your Xsession for remote login, setting paths etc.


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Online

#7 2020-04-10 19:15:28

shadowfirebird
Member
From: Manchester, UK
Registered: 2015-10-25
Posts: 9

Re: GUI Login is not a Bash login session? [SOLVED]

Okay, here's what I've done.

I've created a new file, /etc/X11/Xsession.d/23_shadows_lightdm_fix: 

# Fix for LightDM wont-fix issue: 
# https://bugs.launchpad.net/ubuntu/+source/lightdm/+bug/794315

# First read /etc/profile and .profile
test -f /etc/profile && . /etc/profile
test -f "$HOME/.profile" && . "$HOME/.profile"
 
# Second read /etc/xprofile and .xprofile for X specific setup
test -f /etc/xprofile && . /etc/xprofile
test -f "$HOME/.xprofile" && . "$HOME/.xprofile"

That seems to work!  But if it turns out to be problematic, there's another approach that might work for just $PATH: editing /etc/login.defs, which I think is where bash is getting it's $PATH from at the moment.

Offline

#8 2020-04-11 02:00:55

DeepDayze
Member
From: In Linux Land
Registered: 2017-05-28
Posts: 860

Re: GUI Login is not a Bash login session? [SOLVED]

shadowfirebird wrote:

Okay, here's what I've done.

I've created a new file, /etc/X11/Xsession.d/23_shadows_lightdm_fix: 

# Fix for LightDM wont-fix issue: 
# https://bugs.launchpad.net/ubuntu/+source/lightdm/+bug/794315

# First read /etc/profile and .profile
test -f /etc/profile && . /etc/profile
test -f "$HOME/.profile" && . "$HOME/.profile"
 
# Second read /etc/xprofile and .xprofile for X specific setup
test -f /etc/xprofile && . /etc/xprofile
test -f "$HOME/.xprofile" && . "$HOME/.xprofile"

That seems to work!  But if it turns out to be problematic, there's another approach that might work for just $PATH: editing /etc/login.defs, which I think is where bash is getting it's $PATH from at the moment.

Now that seems like an elegant solution and hopefully easier to customize your $PATH when using a display manager such as LightDM.


Real Men Use Linux

Online

#9 2020-04-11 06:54:45

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,811
Website

Re: GUI Login is not a Bash login session? [SOLVED]

Simple way: edit ~/.xsessionrc instead of ~/.profile

It's not a LightDM "issue" it's just the way things are done.

.xsessionrc is for X sessions, and is read by Lightdm (and X sessions started by 'startx' on Debian), and is where BunsenLabs sets PATH.
.profile is now considered to be only for TTY logins, at least on Debian.

If you want to keep all settings in your Xsession the same as for TTY sessions you can source .profile in .xsessionrc:

if [ -r ~/.profile ]; then . ~/.profile; fi

Debian discussion back in 2011: https://bugs.debian.org/cgi-bin/bugrepo … bug=636108
Debian Wiki on Xsession: https://wiki.debian.org/Xsession

---
The Arch Wiki is indeed excellent, but sometimes the Arch Way™ is different, which is why there is no /etc/lightdm/Xsessions.conf in Debian.

Last edited by johnraff (2020-04-11 06:58:54)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Offline

#10 2020-04-11 16:39:13

DeepDayze
Member
From: In Linux Land
Registered: 2017-05-28
Posts: 860

Re: GUI Login is not a Bash login session? [SOLVED]

johnraff wrote:

Simple way: edit ~/.xsessionrc instead of ~/.profile

It's not a LightDM "issue" it's just the way things are done.

.xsessionrc is for X sessions, and is read by Lightdm (and X sessions started by 'startx' on Debian), and is where BunsenLabs sets PATH.
.profile is now considered to be only for TTY logins, at least on Debian.

If you want to keep all settings in your Xsession the same as for TTY sessions you can source .profile in .xsessionrc:

if [ -r ~/.profile ]; then . ~/.profile; fi

Debian discussion back in 2011: https://bugs.debian.org/cgi-bin/bugrepo … bug=636108
Debian Wiki on Xsession: https://wiki.debian.org/Xsession

---
The Arch Wiki is indeed excellent, but sometimes the Arch Way™ is different, which is why there is no /etc/lightdm/Xsessions.conf in Debian.

Ahh, that makes good sense and thanks @johnraff for making it a simple solution for what the OP is looking for.


Real Men Use Linux

Online

Board footer

Powered by FluxBB