[opensuse-factory] A detailed rundown on how SDDM starts a session and a dive in its complexity
I usually start Xorg using startx from a console (in multi-user target, aka runlevel 3) and a simple ~/.xinitrc file that initializes a few things before starting the i3 Window Manager. This is not the recommeded way to start Xorg but it works fine. But this post is not about that. Recently, I wanted to use the standard login method with SDDM, so I naturally switched to graphical target. When I logged in with the SDDM greeter, whatever the session I chose (Plasma, i3, twm), my session started with i3, exactly as if my ~/.xinitrc config was executed. After a brief WTF, I concluded that SDDM called my ~/.xinitrc for all sessions, for some reason (this was unexpected). So it was a good excuse to dig deeper to understand exactly how SDDM starts a session (something I wanted to do for a long time) and why it called ~/.xinitrc. I started reading the man page and other documentation attentively (hello Arch Wiki!). Let's start from the config file in /usr/lib/sddm/sddm.conf.d/00-general.conf [XDisplay] ServerPath=/usr/bin/X SessionCommand=/etc/X11/xdm/Xsession DisplayCommand=/etc/X11/xdm/Xsetup MinimumVT=7 # boo#1089932 EnableHiDPI=true [Users] # boo#979775 ReuseSession=true So our session is started by the /etc/X11/xdm/Xsession script part of the 'xdm' package. This has been changed from the default /usr/share/sddm/scripts/Xsession, which is still packaged in the 'sddm' package but not used. There are surely reasons for that but /etc/X11/xdm/Xsession is a tad more complicated than /usr/share/sddm/scripts/Xsession. To understand what /usr/share/sddm/scripts/Xsession do, I simply followed the spaghetti, taking notes to keep track of it, and here's the rundown: 1. /etc/X11/xdm/Xsession ===================== - invoked by /usr/lib/sddm/sddm-helper (an executable) - run explicitely with bash shebang - aborts with message "Login for $USER is disabled" if script is called without a $SHELL found in /etc/shells - Redirects errors to the standard user log files (?) with esoteric shell code - source /etc/profile.d/lang.sh: a convoluted script that "Set interactive language environment" - parse some environment parameters passed on the command-line. For sddm, there are none. Only passed parameter (by sddm-helper) is the full path to the executable corresponding to the session selected by user. For example, /usr/bin/startplasma-x11 for a Plasma session - set WINDOWMANAGER env variable to the passed executable (/usr/bin/startplasma-x11) - source /etc/X11/xinit/xinitrc.common (see 2) - call exec_login function which calls /etc/X11/xdm/sys.xsession with a login shell (see 3): exec -l -a bash /bin/bash --login -c 'exec "${@}"' - /etc/X11/xdm/sys.xsession 2. /etc/X11/xinit/xinitrc.common =========================== # Common code used in X session and X init scripts. # File shall be sourced but not executed by the scripts. - keep track if it has already been included, setting XSESSION_IS_UP=yes, to avoid being sourced multiple times - set TERM=xterm - run scripts in /etc/X11/xinit/xinitrc.d, either sourced (if containing '# to be sourced' line, or execute if starting with XX number: 50-systemd-user.sh: import DISPLAY and XAUTHORITY env varaible into systemd --user, as well as dbus-update-activation-environment libcanberra-gtk-module.sh: export GTK_MODULES=canberra-gtk-module xdg-user-dirs.sh: calls /usr/bin/xdg-user-dirs-update. From man: "xdg-user-dirs-update is normally run automatically at the start of a user session to update the XDG user dirs according to the users locale." - set a default WINDOWMANAGER if not already set (/etc/X11/xdm/Xsession has already set it) - source ~/.xim or /etc/X11/xim: another rather convoluted script - set numlock state with numlockx [note: doesn't work on my laptop: does nothing] - call nvidia-settings if ~/.nvidia-settings-rc exists - handle system's and/or user's Xkbmap (x)or user's Xmodmap. Priority: 1. User's xkb -> 2. User's xmodmap -> 3. System's xkb - load the system and the users X resources with xrdb: if ~/.Xdefaults exists: loads /etc/X11/Xresources then merge ~/.Xdefaults and ~/.Xresources (if it exists) else if ~/.Xresources exists: loads /etc/X11/Xresources then merge ~/.Xresources 3. /etc/X11/xdm/sys.xsession =========================== - execute scripts in /etc/X11/xdm/scripts/ : 09-ssh-vars: set usessh variable to yes or no, affecting following scripts 10-gpg-agent: complicated script that supposedly eventually starts gpg-agent depending on alignment of stars... 11-ssh-agent: same for ssh-agent + set some SSH env vars 20-dbus: export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus 30-console-kit: Does nothing: check if ConsoleKit is required for e.g. plain xdm sessions (outdated due systemd login manager) - execute ~/.xinitrc (if present) or /etc/X11/xinit/xinitrc (see 4) 4. /etc/X11/xinit/xinitrc ========================= - source /etc/X11/xinit/xinitrc.common (see 2. Will do nothing here as already executed !) - exec $WINDOWMANAGER (set previously in /etc/X11/xinit/xinitrc.common) ////////////////////////// So in the end, I know why ~/.xinitrc is called by SDDM (or rather /etc/X11/xdm/Xsession), whatever the session selected. And know I know how to make the distinction between ~/.xinitrc called by startx or SDDM and handle it accordingly: in the later case $WINDOWMANAGER is defined. As a bonus, here's a rundown of /etc/X11/xdm/Xsetup started to configure Xorg before SDDM shows up: /etc/X11/xdm/Xsetup =================== - run explicitely with bash shebang - check for xdm,kdm,gdm with some kde3 and gnome 2 stuff (obsolete ?) - set background - set numlock state with numlockx - load xrdb resources from /etc/X11/Xresources - eventually set screensaver / enable dpms with xset (disabled by default in script) - set default keymap with xmodmap or xkbcomp -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sunday, 2020-01-19 at 16:35 +0100, Michael Pujos wrote:
I usually start Xorg using startx from a console (in multi-user target, aka runlevel 3) and a simple ~/.xinitrc file that initializes a few things before starting the i3 Window Manager. This is not the recommeded way to start Xorg but it works fine. But this post is not about that.
Recently, I wanted to use the standard login method with SDDM, so I naturally switched to graphical target. When I logged in with the SDDM greeter, whatever the session I chose (Plasma, i3, twm), my session started with i3, exactly as if my ~ /.xinitrc config was executed. After a brief WTF, I concluded that SDDM called my ~/.xinitrc for all sessions, for some reason (this was unexpected).
So it was a good excuse to dig deeper to understand exactly how SDDM starts a session (something I wanted to do for a long time) and why it called ~/.xinitrc.
Thanks. Keeping this post for reference :-) - -- Cheers, Carlos E. R. (from openSUSE 15.1 x86_64 at Telcontar) -----BEGIN PGP SIGNATURE----- iHoEARECADoWIQQZEb51mJKK1KpcU/W1MxgcbY1H1QUCXjKyQxwccm9iaW4ubGlz dGFzQHRlbGVmb25pY2EubmV0AAoJELUzGBxtjUfVz8oAnivpOwbQCWBXP8tZQxs2 kNrkQYkgAKCQlMZW36GbqSXHb35/9mp/YkTM3w== =ljfh -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-factory+owner@opensuse.org
participants (2)
-
Carlos E. R.
-
Michael Pujos