You are not logged in.

#1 2016-02-03 18:11:27

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Dissecting the graphical startup in bunsenlabs.

From the top down...

1. lightdm.
=========

Started by systemd.
Debugging is possible (from 'man lightdm') by adding the -d option.

Where?
In the unit file /lib/systemd/system/lightdm.service

What?
ExecStart=/usr/sbin/lightdm -d

Where does the output go?
/var/log/lightdm/lightdm.log

Lightdm configuration
Lightdm loads its configuration files from a set of directories in a
specific order.
From least important to most important:
1. Using XDG_DATA_DIRS
   XDG_DATA_DIRS, if set, contains a colon separated list of directories.
   When XDG_DATA_DIRS is not set, it defaults to "/usr/local/share:/usr/share".
   The most preferred directories come first in XDG_DATA_DIRS.
   Lightdm appends lightdm/lightdm.conf.d to these directories and processes them in reverse order. Eventual files within these directories are processed in alphabethical order.
   The files in lightdm.conf.d can contain configuration snippets in stead of full configuration files.

2. Using XDG_CONFIG_DIRS
   XDG_CONFIG_DIRS, if set, should contain a colon separated list of directories.
   When XDG_CONFIG_DIRS is not set, it defaults to "/etc/xdg"
   The most preferred directories come first in XDG_CONFIG_DIRS.
   Lightdm appends lightdm/lightdm.conf.d to these directories and processes them in reverse order. Eventual files within these directories are processed in alphabethical order.
   The files in lightdm.conf.d can contain configuration snippets in stead of full configuration files.

3. Using "/etc/lightdm/lightdm.conf.d"
   The files in lightdm.conf.d can contain configuration snippets in stead of full configuration files.

4. Using /etc/lightdm.conf

Lightdm combines snippets from all these possible configuration files.
To see which configuration options come from which configuration file, you can run:

/usr/sbin/lightdm --show-config

Example output for a test configuration of mine:

 /h/m/t/t/l/l/common /usr/sbin/lightdm --show-config
   [SeatDefaults]
A  greeter-session=lightdm-greeter
C  greeter-hide-users=true
A  session-wrapper=/etc/X11/Xsession
C  session-setup-script=/usr/lib/bunsen/configs/bl-user-setup-test

   [LightDM]
C  start-default-seat=true
D  xserver-command=X --test  server command to run (can also contain arguments e.g. X -special-option)

Sources:
A  /usr/share/lightdm/lightdm.conf.d/01_debian.conf
B  /usr/share/lightdm/lightdm.conf.d/50_bunsen.conf
C  /usr/local/share/lightdm/lightdm.conf.d/50_bunsen.conf
D  /etc/lightdm/lightdm.conf

Conclusions?

[+19.19s] DEBUG: Session pid=690: Running command /etc/X11/Xsession default

-> lightdm runs /etc/X11/Xsession with one argument: 'default'

How does it run /etc/X11/Xsession?
TODO To be determined from  the lightdm source code.

2. /etc/X11/xsession.

How to debug?
By inserting 'set -x' after the exec command which redirects output to $HOME/.xsession-errors.

Where does the output go?
$HOME/.xsession-errors

Conclusions?
TODO

To be continued.

Offline

#2 2016-02-03 20:05:45

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Re: Dissecting the graphical startup in bunsenlabs.

I'm liking where this is going.... A TINY request! Could you modify your Q&A so that the questions are in bold, and answers in plain? or vice versa?  I like the logging feature...


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#3 2016-02-04 07:38:03

hhh
Meep!
Registered: 2015-09-17
Posts: 9,280
Website

Re: Dissecting the graphical startup in bunsenlabs.

@good doctor, My beer buzz is a little too heavy right now to fully understand this, but I'm intrigued about your idea of a donut-shaped universe and I'd like to subscribe to your newsletter.

Offline

#4 2016-05-31 08:58:11

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: Dissecting the graphical startup in bunsenlabs.

Updated the top post with lightdm configuration info.

@johnraff,
Configuration of lightdm can be simplified by just dropping the bunsenlabs specific configuration options in /usr/share/lightdm/lightdm.conf.d/50_bunsen.conf with content:

[SeatDefaults]
greeter-hide-users=true
session-setup-script=/usr/lib/bunsen/configs/bl-user-setup

Advantages:
1. No more file diversion needed for lightdm in package  bunsen-configs
2. The snippet is not a config file any more. It can be overwritten by a new version without the user having to confirm that he accepts the changes.

Offline

#5 2016-05-31 20:41:22

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: Dissecting the graphical startup in bunsenlabs.

I must have missed this somehow the first time around -- this is a fantastic guide, thanks xaos!
smile

Off-topic: have you ever read Ulysses?

The OP reminds me of the catechism section in episode 17 glasses


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

#6 2016-06-01 04:02:01

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

Re: Dissecting the graphical startup in bunsenlabs.

xaos52 wrote:

Configuration of lightdm can be simplified by just dropping the bunsenlabs specific configuration options in /usr/share/lightdm/lightdm.conf.d/50_bunsen.conf

Excellent idea!! Thank you. I'll upgrade bunsen-configs soon. Can we drop some lightdm-gtk-greeter code there too?
*.d directories are so useful. cool

2. /etc/X11/xsession.

How to debug?
By inserting 'set -x' after the exec command which redirects output to $HOME/.xsession-errors.

Where does the output go?
$HOME/.xsession-errors

Conclusions?
TODO

Some years ago I did an exploration of the startx command chain on the #! forum. /etc/X11/xsession came here. I think it mostly still applies.


...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

#7 2016-06-01 06:53:15

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: Dissecting the graphical startup in bunsenlabs.

johnraff wrote:

Can we drop some lightdm-gtk-greeter code there too?

I have not explored the lightdm-gtk-greeter code yet, but I plan to.
Will let you know when I have an answer. wink

HoaS wrote:

The OP reminds me of the catechism section in episode 17 glasses

Ha ha. Yes I read ulysses. Don't remember that section though.
But I do remember catechism lessons from when I was 12 or so. We then had to learn all those questions and answers by heart.

BTW:
Never configure

[LightDM]
start-default-seat=false

or you will find yourself unable to login, getting the login screen back  in a loop even if  your credentials are correct.

Offline

#8 2016-06-01 08:49:41

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: Dissecting the graphical startup in bunsenlabs.

@johnraff,

Just had a quick peek at lightdm-gtk-greeter sources and it looks like the program only loads one config file:

/etc/lightdm/lightdm-gtk-greeter.conf

So it looks like we need to keep using file diversion for that one.

Offline

#9 2016-06-01 09:31:36

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: Dissecting the graphical startup in bunsenlabs.

How to debug lightdm (or any other compiled program) interactively?

1. Install the source package

apt-get source lightdm

2. cd into the top directory

3. Install build dependencies

sudo apt-get build-dep lightdm

4. Compile from source using debugging info and nostrip:

DEB_BUILD_OPTIONS="nostrip noopt" dpkg-buildpackage -us -uc|& tee ../buildpackage.log

This will drop some .deb files into the parent directory.
5. Install the one we need

sudo gdebi lightdm_1.10.3-3_amd64.deb

6. Now cd into lightdm-1.10.3/src (Not absolutely necessary but makes it easier to set breakpoints)

7. Start the debugger

gdb

8. at the gdb prompt enter

(gdb) file /usr/sbin/lightdm

9. You should get back

Reading symbols from /usr/sbin/lightdm...done.

When you get a message that no debug symbols are present, something went wrong during the compilation or installation phase.

10. Set a breakpoint on 'main', run the program, and step through the instructions with 'n'
Use 's' to step into a function.
Use 'help' to see a list of gdb commands.

(gdb) b main
(gdb) run --test-mode --debug
(gdb) c
(gdb) n

'n' is short for 'next'
'c' is short for 'continue to the next breakpoint'
's' is short for 'step'
'return' is for 'returning from current function'
'bt' is short for 'backtrace' and lets you see the 'call stack'

Use Ctrl+C to break the session

If you want to restart your program, just enter the 'run' command again.

Use your editor to  see the source code (lightdm.c) in the background.

There is no better way to explore exactly what a compiled program is doing.
And it is fun (if you are into that sort of things)


Happy debugging smile

Offline

Board footer

Powered by FluxBB