You are not logged in.

#1 2022-02-06 10:49:02

musbur
Member
Registered: 2022-01-14
Posts: 74

[SOLVED] Why does lightdm run ~/.xsession twice?

Hello,

noticed that I had to quit dwm twice to exit an X session. It doesn't bother me much, but I devided to investigate.

Simpy enough, after login lightdm runs the script /etc/lightdm/Xsession, which looks like this towards the end:

# Run user xsession shell script
script="$HOME/.xsession"
if [ -x "$script" -a ! -d "$script" ]; then
    echo "Loading xsession script $script"
    . "$script"
fi

echo "X session wrapper complete, running session $@"

exec $@

Here's the relevant part of my ~/.xsession

#!/bin/sh

start_some_background_job &
bgproc=$!
/usr/bin/dwm
kill $bgproc

To me it's pretty obvious what happens: /etc/lightdm/Xsession checks for the presence of an .xsession file in the user's $HOME and sources that. And then, at the very end, it exec's that same script again. I didn't notice earlier because my ~/.xsession would "exec" dwm, thus replacing the whole process with dwm so that  /etc/lightdm/Xsession script never gets to its own "exec $@" line. When I added some background process that needs killing post-dwm in ~/.xsession, that obviously didn't work any more.

So I think I know what's going on, I also know how to fix it (by reducing /etc/lightdm/Xsession to just the statement "exec $@"), but I'd like to know what the rationale is of first sourcing ~/.xsession and then exec'ing it.

Last edited by musbur (2022-02-08 21:37:35)

Offline

#2 2022-02-06 14:17:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,499
Website

Re: [SOLVED] Why does lightdm run ~/.xsession twice?

musbur wrote:

To me it's pretty obvious what happens: /etc/lightdm/Xsession checks for the presence of an .xsession file in the user's $HOME and sources that. And then, at the very end, it exec's that same script again.

No, it does not exec the same script, it exec's whatever was passed as an argument to Xsession (which is likely just "dwm" though I'm not sure quite how it works).  I gather the intent is for ~/.xsession to contain everything but the actual WM, like any startup / background processes; then the wm is exec'ed by Xsession.  But I've always found DEs to serve little purpose other than to add useless complexity and break things (and in this case to be poorly documented).  So you could certainly try to "fix" it - but if you are using DWM, why do you even want a DM?


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2022-02-07 11:48:57

musbur
Member
Registered: 2022-01-14
Posts: 74

Re: [SOLVED] Why does lightdm run ~/.xsession twice?

Trilby wrote:

But I've always found DEs to serve little purpose other than to add useless complexity and break things (and in this case to be poorly documented).  So you could certainly try to "fix" it - but if you are using DWM, why do you even want a DM?

Good question. At first I didn't have any DM and just used "sx" after login from the text console, but I somehow didn't "like" it. No particular reason. There are more possibilities:

1) Start dwm automatically after console login via .bash_profile (or .bashrc?), but for that I'd finally have to wrap my head around login vs. no-login console and how that plays with tmux etc.

2) Since the whole system runs from an encrypted disk that I have to unlock anyway, I might just start dwm with my user directly with no additional login at all, but I don't know how to make that work and what would happen after I quit dwm. Also I have a separate "test" user with their own desktop environment, and I guess that couldn't be started at all if there is a permanent DE for the main user.

Offline

#4 2022-02-07 13:28:16

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,499
Website

Re: [SOLVED] Why does lightdm run ~/.xsession twice?

musbur wrote:

I might just start dwm with my user directly with no additional login at all, but I don't know how to make that work

https://wiki.archlinux.org/title/Xinit# … X_at_login
https://wiki.archlinux.org/title/Automa … al_console

musbur wrote:

Also I have a separate "test" user with their own desktop environment, and I guess that couldn't be started at all if there is a permanent DE for the main user.

Ah, no - that's not true, nor related in any way.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2022-02-08 21:38:36

musbur
Member
Registered: 2022-01-14
Posts: 74

Re: [SOLVED] Why does lightdm run ~/.xsession twice?

Everything works fine now ... I didn't even know that one could run several X sessions in parallel for different users... I always thought there was one X screen and bunch of virtual consoles. Thanks!

Offline

Board footer

Powered by FluxBB