GNOME-SESSION(1)

โœจ NAME โœจ

okay so real quick โ€” gnome-session is the manual page GNOME-SESSION(1), and it does exactly one extremely iconic thing: it starts the GNOME desktop environment. periodt. ๐Ÿ’…


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

gnome-session [OPTION...]

๐ŸŒธ DESCRIPTION ๐ŸŒธ

gnome-session starts up the whole entire GNOME desktop environment. bestie, this is the program that makes your screen become GNOME. โœจ

It's normally launched for you by your login manager โ€” so like GDM, SDDM, lightdm, or whatever other one you're running. You're usually not typing this yourself, it just happens when you log in. ๐Ÿซถ

When it runs, it will either load your saved session, or it will give you a default session for the user โ€” and that default is defined by the system administrator (or, you know, whatever the default GNOME installation on your system ships with).

The default session lives in gnome.session, which is a .desktop-like file. Here's where it goes looking for it: ๐Ÿ”

  • $XDG_CONFIG_HOME/gnome-session/sessions
  • $XDG_CONFIG_DIRS/gnome-session/sessions
  • $XDG_DATA_DIRS/gnome-session/sessions

๐Ÿ’– OPTIONS ๐Ÿ’–

  • --session=SESSION โ€” runs the applications defined in SESSION.session. If you don't pass this at all, gnome.session gets used instead. no thoughts, just defaults. ๐ŸŽ€
  • --debug โ€” turns on debugging code. for when you wanna see the whole tea. ๐Ÿต

๐Ÿ‘‘ SYSTEMD ๐Ÿ‘‘

ngl, this part is kind of the main character. gnome-session uses systemd for the bulk of its service management โ€” that's just how it does things now. ๐Ÿ’ซ

systemd provides two special targets for desktop integration:

  • graphical-session.target
  • graphical-session-pre.target

These two work across desktop environments, so use them if you possibly can. fr fr, that's the recommendation.

On top of that, gnome-session gives you these extra GNOME-specific targets:

  • gnome-session.target โ€” a generic unit that stays active throughout the entire session. it's basically the sibling of graphical-session.target.
  • gnome-session-pre.target โ€” for tasks that need to happen before session startup. the sibling of graphical-session-pre.target.
  • gnome-session@SESSION.target โ€” the main unit that gets started for the session. SESSION here is set according to whatever session got passed in through --session.
  • gnome-session-basic-services.target โ€” a special unit listing the basic services needed by any GNOME session built around gnome-shell. this one exists so kiosk sessions โ€” like the GDM login screen โ€” can conveniently reuse it. ๐Ÿงš
  • gnome-session-x11-services.target โ€” a special unit that starts up when X11 services are needed. heads up: programs will need to use the special GNOME_SETUP_DISPLAY environment variable instead of DISPLAY. yes really, not DISPLAY. ๐Ÿ™ˆ
โš ๏ธ now listen, bestie, this is the part where you have to be careful: you must take care to set appropriate After= rules. And it's strongly recommended that you always do that in combination with BindsTo= or PartOf= on one of the core targets (for example graphical-session.target).
โš ๏ธ also: units are required to set CollectMode=inactive-or-failed. and on top of that, it is strongly recommended to set TimeoutStopSec=5, so that logout doesn't get delayed indefinitely in case the process doesn't stop properly. don't skip this one, you'll be sitting there waiting to log out forever. ๐Ÿ’€

๐ŸŒˆ SESSION DEFINITION ๐ŸŒˆ

Sessions are defined in .session files, and those use a .desktop-like format. Inside them, in the GNOME Session group, you get these keys:

  • Name โ€” the name of the session. this one can be localized. ๐ŸŒ
  • Kiosk โ€” okay so kiosk sessions are these special single-purpose sessions built around starting one specific app. like, a kiosk session might run a full-screen web browser that's locked to one specific page. in GNOME we use kiosk sessions for the login screen (where the app is the login screen UI) and for the initial-setup first boot experience. when this is set to true, gnome-session will make no attempt to autostart any .desktop files at all โ€” instead it will require that the session configures all required functionality via systemd. all of it. no autostart, not even a little. ๐Ÿ‘‘

Here's an example of a session definition:

[GNOME Session]
Name=GNOME

The .session files are loaded from:

  • $XDG_CONFIG_HOME/gnome-session/sessions
  • $XDG_CONFIG_DIRS/gnome-session/sessions
  • $XDG_DATA_DIRS/gnome-session/sessions

Important vibe check: session definitions don't do anything on their own. they're nothing without systemd configuration to actually provide functionality (i.e. launch services). the recommended way to do that is by hooking into one of the targets described above. ๐Ÿ’ซ

For instance: when you're defining a session named foobar, you can create a systemd drop-in file in /etc/systemd/user/gnome-session@foobar.target.d/session.conf and define Requires= and Wants= dependencies to tell systemd what services it needs to start when launching this session. literally that easy. ๐ŸŽ€


๐Ÿ“ FILES ๐Ÿ“

$XDG_CONFIG_HOME/autostart
$XDG_CONFIG_DIRS/autostart
/usr/share/gnome/autostart

Applications defined via .desktop files in those directories will be started on login. ๐Ÿ“Œ but ngl, note this: previous versions of gnome-session would launch services from here, and that is no longer the case. services should now be configured via systemd unit files. the old way is over, we've moved on. ๐Ÿ’…

$XDG_CONFIG_HOME/gnome-session/sessions
$XDG_CONFIG_DIRS/gnome-session/sessions
$XDG_DATA_DIRS/gnome-session/sessions

These directories contain the .session files that you can use with the --session option. ๐ŸŒธ


๐Ÿ˜ญ BUGS ๐Ÿ˜ญ

If you find bugs in the gnome-session program, please report them here: https://gitlab.gnome.org/GNOME/gnome-session/issues. do it, they wanna know. ๐Ÿซถ


โญ SEE ALSO โญ

gnome-session-quit(1)


and that's the whole page, bestie!! this was gnome-session from GNOME-SESSION(1) โ€” yes, the manual is literally named the same thing as the program, iconic behavior honestly. go forth, log in, and let systemd handle the rest. mwah ๐Ÿ’–โœจ๐ŸŽ€๐Ÿฆ‹๐ŸŒธ

๐Ÿ“ฆ where this page comes from