canonical / lightdm

Display Manager
GNU General Public License v3.0
824 stars 138 forks source link

How to let lightdm source the ~/.profile while user logging in? #96

Open hongyi-zhao opened 4 years ago

hongyi-zhao commented 4 years ago

Hi,

I use Debian 10 with xfce, which use lightdm as the display manager. But I found the the ~/.profile will not be sourced when I logging into my desktop.

How to let lightdm source the ~/.profile when the user logs in?

Regards

graemev commented 4 years ago

I'm using cinnamon under lightdm on buster. I also find that ~/.profile is not being sourced. All the documents suggest it should be. Using gdm3 results in ~/.profile being sourced.

moonwitch commented 4 years ago

I had the same issue, rather than trying to 'fix' it; I just opted for what I know. Source ~/.profile in ~/.xprofile. .xprofile is loaded by lightdm.

#!/bin/sh

# sourced at boot by ~/.xinitrc and most display managers

source ~/.profile
graemev commented 4 years ago

Interesting, helpful pointer, I actually worked around it be doing things in ~/.xsessionrc :


# Private profile extension
if [ -r "$HOME/.local/profile" ] ; then
    . ${HOME}/.local/profile
fi

This is all a little random however, as gdm(1) does one thing xdm(1) another and lightdm(1) a third. This would be simply annoying, but borderline acceptable if any of these documented this behaviour in their man pages!!

I only switched to lightdm(1) because of yet more bugs in gdm(1) where they they did not follow the documentation on their own web site. If we're not careful we will end up in a M$ type world, where it's "all just magic" and people only discover how stuff works by rumour.

Personal I feel all the GUI developers got this one wrong. There is a shell somewhere that is "the initial shell" but, sadly, that ship has sailed.

hongyi-zhao commented 4 years ago

I finally discarded lightdm.

moonwitch commented 4 years ago

Out of curiosity, what are you using now? I've tried GDM, which was ok. SDDM was hell.

hongyi-zhao commented 4 years ago

@moonwitch GDM

Generally speaking, only gdm and kdm are the most powerful/stable ones after many tries on many such tools.

duanyao commented 4 years ago
    wget https://github.com/canonical/lightdm/blob/master/debian/lightdm-session
    chmod +x lightdm-session
    sudo cp lightdm-session /usr/sbin/lightdm-session

Edit /etc/lightdm/lightdm.conf , uncomment session-wrapper=lightdm-session . Reboot. ~/.profile should be source.

chmduquesne commented 2 years ago

@duanyao your workaround does the trick, however the url was wrong (you get an html file). Here is what worked for me:

    wget https://raw.githubusercontent.com/canonical/lightdm/master/debian/lightdm-session
    chmod +x lightdm-session
    sudo cp lightdm-session /usr/sbin/lightdm-session

Edit /etc/lightdm/lightdm.conf , uncomment session-wrapper=lightdm-session.

hongyi-zhao commented 2 years ago

Edit /etc/lightdm/lightdm.conf ,

On Ubuntu 20.04.3 LTS, the file is at the following location:

$ apt-file search -x /etc/.*/lightdm.conf$
lightdm: /etc/init/lightdm.conf  

uncomment session-wrapper=lightdm-session.

And it doesn't include the above line at all:

$ grep -i session-wrapper /etc/init/lightdm.conf  
$ 
D-Pow commented 2 years ago

Better yet, @lightdm can you provide a way to toggle this? I'm experiencing the opposite problem where lightdm is sourcing $HOME/.profile and it causes my system to crash (see issue #234).

sonjiku commented 2 years ago

@D-Pow you should have an Xsession script in /etc/lightdm/. Just modify that, or better yet, copy it and modify it to fit your needs. Then change the path for session-wrapper in lightdm.conf, or whatever it's called. I lost a day jumping through a bunch of different DMs, because profile wasn't being sourced in sway using lightdm for some reason. It's dumb really.

maxnikulin commented 1 year ago

Not loading profile files is not an upstream bug, but Debian-specific behavior. The upstream repository and Ubuntu packages contains the /usr/sbin/lightdm-session script used as session-wrapper. Debian just loads /etc/X11/Xsession.

From my point of view, /etc/sddm/Xsession from SDDM may be more friendly to shells other than BASH.

Nickwiz commented 6 months ago

Not sure why, but this changed for me on Arch after last upgrade. I have likely done some changes I have forgotten about since last boot. (57 days+ :0).

Anyhow; From lightdm.conf one have:

$ grep session-wrapper /etc/lightdm/lightdm.conf
# session-wrapper = Wrapper script to run session with
session-wrapper=/etc/lightdm/Xsession

Looking at /etc/lightdm/Xsession it has a switch where; if shell is:

~/.xprofile is always sourced if it exists.

As for for example bash it executes it with the --login option. I.e. it leaves the task for bash to resolve. There one have specified that it sources by precedence

  1. ~/.bash_profile
  2. ~/.bash_login
  3. ~/.profile

So if one have either of the first two, ~/.profile will not be sourced (by bash itself).

zsh does not source it no matter what.

As such; using .xprofile can be the most stable. (All depending on usage). If one have .bash_profile or .bash_login one can add a simple check in either; just remember order. E.g.

[ -f "$HOME/.profile" ] && . "$HOME/.profile"

So some places to source it could be: