systemd has a service for managing user sessions called logind(8), this replaces the existing ConsoleKit tool, which was the previous cross-desktop and cross-distribution tool.
This caused some controversy, as logind(8) is not usable without systemd, and the fear was that this would cause distributions to force the use of systemd.
There was some misplaced anger at both the systemd developers and the GNOME developers, when the GNOME package maintainers in Debian decided to build GNOME without ConsoleKit support, as GNOME still supported being built with ConsoleKit, and the systemd developers are not responsible for other developers' decisions to support logind(8) exclusively.
So, controversy aside, what does logind(8) provide to us?
User session management
logind(8) tracks user log-ins and keeps track of which processes are used, by use of a pam_systemd PAM module, so that processes can be cleaned up when a user logs out, or the user is forced to log out, such as when the administrator needs to perform maintainance, or the user is no longer permitted to use the server.
There's little to no configuration needed by users for this aspect of
logind(8), but if a user should be allowed to run processes after
they log out, such as if they run a screen(1) session, then this can
be allowed by using loginctl(1) to run loginctl enable-linger $USER
.
Seat assignment
It's common these days for everybody to have their own computer, and the only shared computers are servers, which you interact with via your local comptuer, over a network.
However, back in the day, it was more common for there to be 1 computer shared directly to multiple users, each with their own physical terminal.
Personal computing has made shared machines with multiple terminals mostly unnecessary, but there's still a few uses, such as kiosks, internet cafes, or classrooms, where it would be more cost efficient to have people sharing the computer.
To make this work, systemd supports Multiseat configuration, by assigning multiple physical devices, such as a display, a keyboard and a mouse, to different seats.
Some hardware is automatically configured as a separate seat, but
hardware can be explicitly assigned to a seat if these automatic rules
are incorrect, by using loginctl attach SEAT DEVICE_PATH
.
Hardware sleep
If your computer is battery powered you may want the machine to go to sleep when idle to save power, or you may want to block a system reboot while performing crucial operations, like a system update.
To handle this, logind(8) allows you to take an inhibit lock, which is implemented with file descriptor passing, so a crashing process will automatically release it.
To use an inhibitor lock, either run a command with the systemd-inhibit(1) wrapper command, or request a file descriptor with the logind D-Bus interface.