ORG.FREEDESKTOP.LOGIN1(5)

๐Ÿ’– org.freedesktop.login1 ๐Ÿ’–

okay bestie, so this is org.freedesktop.login1 โ€” that's the manual page name, and it lives in section 5 of the manual (the "file formats and conventions" girlies) under the org.freedesktop.login1 collection. It's literally the tea on the D-Bus interface of systemd-logind. ๐Ÿซถ


โœจ NAME โœจ

org.freedesktop.login1 โ€” the D-Bus interface of systemd-logind, no cap ๐Ÿ’…


๐ŸŒธ INTRODUCTION ๐ŸŒธ

So systemd-logind.service(8) is a system service, right? And her whole job โ€” her entire main character arc โ€” is keeping track of user logins and seats. She's the one watching the door, counting who's in the building and which chair they're sitting in. ๐Ÿ‘‘

And the daemon serves up two whole interfaces, not just one:

  • a C library interface, and
  • a D-Bus interface

The library interface is the chill one โ€” you can use it to introspect and watch the state of user logins and seats. Basically look, don't touch. ๐Ÿ‘€

The bus interface does all of that too, but ALSO โ€” and this is the iconic part โ€” it may also be used to make changes to the system state. So like, it can actually do stuff, not just gossip about it. โœจ

If you want more info on that, please go consult sd-login(3). She has the lore. ๐Ÿ“š


๐Ÿ‘‘ THE MANAGER OBJECT ๐Ÿ‘‘

The service exposes the following interfaces on the Manager object on the bus:


(and bestie we are SO not done โ€” there's more coming, don't go anywhere ๐ŸŒˆ)

okay bestie, deep breath, because this is the moment ๐Ÿ’… here's the whole shape of the Manager object โ€” every method it answers to, every signal it throws out into the void, every property it's holding onto. it's giving the entire menu of the restaurant ๐Ÿ“ and honestly? it eats. do not let the wall of text scare you, we're gonna walk through all of it together, no cap.

           node /org/freedesktop/login1 {
             interface org.freedesktop.login1.Manager {
               methods:
                 GetSession(in  s session_id,
                            out o object_path);
                 GetSessionByPID(in  u pid,
                                 out o object_path);
                 GetUser(in  u uid,
                         out o object_path);
                 GetUserByPID(in  u pid,
                              out o object_path);
                 GetSeat(in  s seat_id,
                         out o object_path);
                 ListSessions(out a(susso) sessions);
                 ListSessionsEx(out a(sussussbto) sessions);
                 ListUsers(out a(uso) users);
                 ListSeats(out a(so) seats);
                 ListInhibitors(out a(ssssuu) inhibitors);
                 @org.freedesktop.systemd1.Privileged("true")
                 CreateSession(in  u uid,
                               in  u pid,
                               in  s service,
                               in  s type,
                               in  s class,
                               in  s desktop,
                               in  s seat_id,
                               in  u vtnr,
                               in  s tty,
                               in  s display,
                               in  b remote,
                               in  s remote_user,
                               in  s remote_host,
                               in  a(sv) properties,
                               out s session_id,
                               out o object_path,
                               out s runtime_path,
                               out h fifo_fd,
                               out u uid,
                               out s seat_id,
                               out u vtnr,
                               out b existing);
                 @org.freedesktop.systemd1.Privileged("true")
                 CreateSessionWithPIDFD(in  u uid,
                                        in  h pidfd,
                                        in  s service,
                                        in  s type,
                                        in  s class,
                                        in  s desktop,
                                        in  s seat_id,
                                        in  u vtnr,
                                        in  s tty,
                                        in  s display,
                                        in  b remote,
                                        in  s remote_user,
                                        in  s remote_host,
                                        in  t flags,
                                        in  a(sv) properties,
                                        out s session_id,
                                        out o object_path,
                                        out s runtime_path,
                                        out h fifo_fd,
                                        out u uid,
                                        out s seat_id,
                                        out u vtnr,
                                        out b existing);
                 ReleaseSession(in  s session_id);
                 ActivateSession(in  s session_id);
                 ActivateSessionOnSeat(in  s session_id,
                                       in  s seat_id);
                 LockSession(in  s session_id);
                 UnlockSession(in  s session_id);
                 LockSessions();
                 UnlockSessions();
                 KillSession(in  s session_id,
                             in  s whom,
                             in  i signal_number);
                 KillUser(in  u uid,
                          in  i signal_number);
                 TerminateSession(in  s session_id);
                 TerminateUser(in  u uid);
                 TerminateSeat(in  s seat_id);
                 SetUserLinger(in  u uid,
                               in  b enable,
                               in  b interactive);
                 AttachDevice(in  s seat_id,
                              in  s sysfs_path,
                              in  b interactive);
                 FlushDevices(in  b interactive);
                 PowerOff(in  b interactive);
                 PowerOffWithFlags(in  t flags);
                 Reboot(in  b interactive);
                 RebootWithFlags(in  t flags);
                 Halt(in  b interactive);
                 HaltWithFlags(in  t flags);
                 Suspend(in  b interactive);
                 SuspendWithFlags(in  t flags);
                 Hibernate(in  b interactive);
                 HibernateWithFlags(in  t flags);
                 HybridSleep(in  b interactive);
                 HybridSleepWithFlags(in  t flags);
                 SuspendThenHibernate(in  b interactive);
                 SuspendThenHibernateWithFlags(in  t flags);
                 Sleep(in  t flags);
                 CanPowerOff(out s result);
                 CanReboot(out s result);
                 CanHalt(out s result);
                 CanSuspend(out s result);
                 CanHibernate(out s result);
                 CanHybridSleep(out s result);
                 CanSuspendThenHibernate(out s result);
                 CanSleep(out s result);
                 ScheduleShutdown(in  s type,
                                  in  t usec);
                 CancelScheduledShutdown(out b cancelled);
                 Inhibit(in  s what,
                         in  s who,
                         in  s why,
                         in  s mode,
                         out h pipe_fd);
                 CanRebootParameter(out s result);
                 SetRebootParameter(in  s parameter);
                 CanRebootToFirmwareSetup(out s result);
                 SetRebootToFirmwareSetup(in  b enable);
                 CanRebootToBootLoaderMenu(out s result);
                 SetRebootToBootLoaderMenu(in  t timeout);
                 CanRebootToBootLoaderEntry(out s result);
                 SetRebootToBootLoaderEntry(in  s boot_loader_entry);
                 SetWallMessage(in  s wall_message,
                                in  b enable);
               signals:
                 SecureAttentionKey(s seat_id,
                                    o object_path);
                 SessionNew(s session_id,
                            o object_path);
                 SessionRemoved(s session_id,
                                o object_path);
                 UserNew(u uid,
                         o object_path);
                 UserRemoved(u uid,
                             o object_path);
                 SeatNew(s seat_id,
                         o object_path);
                 SeatRemoved(s seat_id,
                             o object_path);
                 PrepareForShutdown(b start);
                 PrepareForShutdownWithMetadata(b start,
                                                a{sv} metadata);
                 PrepareForSleep(b start);
               properties:
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
                 @org.freedesktop.systemd1.Privileged("true")
                 readwrite b EnableWallMessages = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
                 @org.freedesktop.systemd1.Privileged("true")
                 readwrite s WallMessage = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly u NAutoVTs = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly as KillOnlyUsers = ['...', ...];
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly as KillExcludeUsers = ['...', ...];
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly b KillUserProcesses = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
                 readonly s RebootParameter = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
                 readonly b RebootToFirmwareSetup = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
                 readonly t RebootToBootLoaderMenu = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
                 readonly s RebootToBootLoaderEntry = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly as BootLoaderEntries = ['...', ...];
                 readonly b IdleHint = ...;
                 readonly t IdleSinceHint = ...;
                 readonly t IdleSinceHintMonotonic = ...;
                 readonly s BlockInhibited = '...';
                 readonly s BlockWeakInhibited = '...';
                 readonly s DelayInhibited = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly t InhibitDelayMaxUSec = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly t UserStopDelayUSec = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly as SleepOperation = ['...', ...];
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly s HandlePowerKey = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly s HandlePowerKeyLongPress = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly s HandleRebootKey = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly s HandleRebootKeyLongPress = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly s HandleSuspendKey = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly s HandleSuspendKeyLongPress = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly s HandleHibernateKey = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly s HandleHibernateKeyLongPress = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly s HandleLidSwitch = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly s HandleLidSwitchExternalPower = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly s HandleLidSwitchDocked = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly s HandleSecureAttentionKey = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly t HoldoffTimeoutUSec = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly s IdleAction = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly t IdleActionUSec = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
                 readonly b PreparingForShutdown = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
                 readonly a{sv} PreparingForShutdownWithMetadata = [...];
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
                 readonly b PreparingForSleep = ...;
                 readonly (st) ScheduledShutdown = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")

see how it's literally all here? ๐Ÿ˜ญ the methods: chunk is everything you can ask it to do, the signals: chunk is everything it'll yell at you without being asked, and the properties: chunk is the state it's sitting on. notice the little annotations riding along too โ€” @org.freedesktop.systemd1.Privileged("true") and @org.freedesktop.DBus.Property.EmitsChangedSignal(...) โ€” those are doing real work up in there, keep an eye on 'em ๐Ÿ‘€. also peep the in/out on every parameter, because that's just D-Bus telling you which direction the data flows, and the type signatures like a(susso) or a{sv} are the bus's own little shorthand language, iykyk.

and yeah โ€” the property list keeps rolling right off the edge of this part, so do not touch that scroll wheel like it's done, because we are picking it right back up ๐Ÿ’–

                 readonly s DesignatedMaintenanceTime = '...';
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
                 readonly b Docked = ...;
                 readonly b LidClosed = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
                 readonly b OnExternalPower = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly b RemoveIPC = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly t RuntimeDirectorySize = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly t RuntimeDirectoryInodesMax = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly t InhibitorsMax = ...;
                 readonly t NCurrentInhibitors = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly t SessionsMax = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
                 readonly t NCurrentSessions = ...;
                 @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
                 readonly t StopIdleSessionUSec = ...;
             };
             interface org.freedesktop.DBus.Peer { ... };
             interface org.freedesktop.DBus.Introspectable { ... };
             interface org.freedesktop.DBus.Properties { ... };
           };

โœจ Methods โœจ

okay so this is the good part โ€” all the actual verbs the Manager can do for you ๐Ÿ’– every single one of these lives on org.freedesktop.login1.Manager, and they're all readonly-adjacent in vibe but very much callable. let's go one by one, no skipping, I promise ๐Ÿซถ

  • GetSession() โ€” grabs you the session object path for the session with the specified ID. same energy for GetUser() and GetSeat() โ€” they hand back the user object and the seat object respectively โœจ
  • GetSessionByPID() and GetUserByPID() โ€” these ones take a PID and give you back the session object / user object that PID belongs to, if there is any ๐ŸŒธ like a little "who dis?" lookup.
  • ListSessions() โ€” returns an array of all current sessions. each structure in that array has these fields: session id, user id, user name, seat id, and session object path. ๐Ÿ’… and heads up bestie โ€” if a session doesn't have a seat attached, the seat id field is just an empty string, no drama.
  • ListSessionsEx() โ€” same idea as ListSessions() but with more metadata, it's giving deluxe edition ๐Ÿ‘‘ the structures here consist of: session id, user id, user name, seat id, leader pid, session class, tty name, idle hint, idle hint monotonic timestamp, and session object path. the tty and seat id fields could be empty โ€” if the session has no associated tty, or the session has no seat attached, respectively ๐Ÿ™ˆ
  • ListUsers() โ€” returns an array of all currently logged in users. each structure has: user id, user name, user object path. short and iconic.
  • ListSeats() โ€” returns an array of all currently available seats. each structure: seat id, seat object path. periodt ๐Ÿ’œ
  • ListInhibitors() โ€” lists all currently active inhibitors ๐Ÿ”ฅ returns an array of structures containing: what, who, why, mode, uid (user ID), and pid (process ID).
  • CreateSession(), CreateSessionWithPIDFD(), and ReleaseSession() โ€” these can open or close login sessions. > okay real talk: these calls should never be invoked directly by clients, fr fr ๐Ÿšซ creating/closing sessions is exclusively the job of PAM and its pam_systemd(8) module. don't touch, bestie, it's not your lane ๐Ÿ’€
  • ActivateSession() โ€” brings the session with the specified ID into the foreground, main character energy โœจ ActivateSessionOnSeat() does the exact same thing, but only if the seat id matches ๐Ÿ‘‘
  • LockSession() โ€” asks the session with the specified ID to activate the screen lock ๐Ÿ”’ UnlockSession() asks that session to remove an active screen lock, if there is any. how does it work? it sends out the Lock() and Unlock() signals from the respective session object, and session managers are supposed to be listening for those ๐Ÿ‘€
  • LockSessions() โ€” asks all sessions to activate their screen locks. this is the one you use to lock access to the entire machine in one single action, slay ๐Ÿ’… and yeah, UnlockSessions() asks all sessions to deactivate their screen locks. symmetrical, we love it.
  • KillSession() โ€” sends a Unix signal to one or all processes of a session โ˜ ๏ธ as arguments it takes the session id, either the string "leader" or "all", and a signal number. if "leader" is passed, only the session "leader" is killed. if "all" is passed, all processes of the session are killed. be normal about this one, okay?
  • KillUser() โ€” sends a Unix signal to all processes of a user. arguments: the user id and a signal number. ๐Ÿ˜ญ
  • TerminateSession(), TerminateUser(), TerminateSeat() โ€” these forcibly terminate one specific session, all processes of a user, and all sessions attached to a specific seat, respectively. the session, user, and seat are identified by their respective IDs ๐Ÿ’ฅ
  • SetUserLinger() โ€” enables or disables user lingering ๐Ÿฆ‹ if enabled, the runtime directory of a user is kept around and they may continue to run processes while logged out. if disabled, the runtime directory goes away as soon as they log out. it expects three arguments: the UID, a boolean whether to enable/disable, and a boolean controlling the polkit[1] authorization interactivity (see below). and ngl โ€” the user linger state is persistently stored on disk ๐Ÿ’พ
  • AttachDevice() โ€” assigns a specific device to a specific seat ๐ŸŽ€ the device is identified by its /sys/ path and must be eligible for seat assignments. AttachDevice() takes three arguments: the seat id, the sysfs path, and a boolean for controlling polkit interactivity (see below). device assignments are persistently stored on disk. to create a new seat, simply specify a previously unused seat id ๐ŸŒˆ for more info about the seat assignment logic, see sd-login(3).
  • FlushDevices() โ€” removes all explicit seat assignments for devices, resetting all assignments back to the automatic defaults. the only argument it takes is the polkit interactivity boolean (see below). spring cleaning vibes ๐Ÿงนโœจ
  • PowerOff(), Reboot(), Halt(), Suspend(), and Hibernate() โ€” these result in the system being: powered off, rebooted, halted (shut down without turning off power), suspended (the system state is saved to RAM and the CPU is turned off), or hibernated (the system state is saved to disk and the machine is powered down) ๐Ÿ’ค HybridSleep() puts the system into hybrid-sleep mode, i.e. it's both hibernated and suspended at once. SuspendThenHibernate() suspends the system, then later wakes it using an RTC timer and hibernates it โฐ the only argument is the polkit interactivity boolean interactive (see below).

the main purpose of these calls is that they enforce polkit policy and hence allow powering off/rebooting/suspending/hibernating even by unprivileged users ๐Ÿ‘‘ they also enforce inhibition locks for non-privileged users ๐Ÿ”’

Sleep() automatically selects the most suitable sleep operation supported by the machine. the candidate sleep operations to check for support can be configured through the SleepOperation= setting in logind.conf(5) ๐ŸŒ™ UIs should expose these calls as the primary mechanism to poweroff/reboot/suspend/hibernate the machine โ€” like, that's the assignment, besties ๐Ÿ’…

the methods PowerOffWithFlags(), RebootWithFlags(), HaltWithFlags(), SuspendWithFlags(), HibernateWithFlags(), HybridSleepWithFlags(), SuspendThenHibernateWithFlags(), and Sleep() take flags to allow for extendability, defined as follows:

#define SD_LOGIND_ROOT_CHECK_INHIBITORS          (UINT64_C(1) << 0)
#define SD_LOGIND_KEXEC_REBOOT                   (UINT64_C(1) << 1)
#define SD_LOGIND_SOFT_REBOOT                    (UINT64_C(1) << 2)
#define SD_LOGIND_SOFT_REBOOT_IF_NEXTROOT_SET_UP (UINT64_C(1) << 3)
#define SD_LOGIND_SKIP_INHIBITORS                (UINT64_C(1) << 4)

when the flags is 0 then these methods behave just like the versions without flags ๐Ÿ™Œ since systemd version 257 inhibitors of type "block" are enforced on operations requested by both privileged and unprivileged users. previously they were honoured only by unprivileged users, excluding the user owning the inhibitor. that latter behaviour is now available through the "block-weak" inhibitor lock type ๐Ÿ‘€

SD_LOGIND_ROOT_CHECK_INHIBITORS (0x01) makes "block-weak" locks behave like regular "block" locks, i.e. ensures they are honoured for any user. a flag SD_LOGIND_SKIP_INHIBITORS (0x10) can be specified to bypass both "block" and "block-weak" inhibitors (it has no effect on "delay" inhibitors, jsyk). when SD_LOGIND_KEXEC_REBOOT (0x02) is set, then RebootWithFlags() performs a kexec reboot if a kexec kernel is loaded ๐Ÿ”ฅ when SD_LOGIND_SOFT_REBOOT (0x04) is set, or SD_LOGIND_SOFT_REBOOT_IF_NEXTROOT_SET_UP (0x08) is set and a new root file system has been set up on "/run/nextroot/", then RebootWithFlags() performs a userspace reboot only. SD_LOGIND_SOFT_REBOOT_IF_NEXTROOT_SET_UP and SD_LOGIND_KEXEC_REBOOT can be combined, with soft-reboot having precedence โš–๏ธ

  • SetRebootParameter() โ€” sets a parameter for a subsequent reboot operation. see the description of reboot in systemctl(1) and reboot(2) for more information ๐ŸŽ€
  • SetRebootToFirmwareSetup(), SetRebootToBootLoaderMenu(), and SetRebootToBootLoaderEntry() โ€” configure the action to be taken from the boot loader after a reboot: respectively entering firmware setup mode, the boot loader menu, or a specific boot loader entry โœจ see systemctl(1) for the corresponding command line interface.
  • CanPowerOff(), CanReboot(), CanHalt(), CanSuspend(), CanHibernate(), CanHybridSleep(), CanSuspendThenHibernate(), CanSleep(), CanRebootParameter(), CanRebootToFirmwareSetup(), CanRebootToBootLoaderMenu(), and CanRebootToBootLoaderEntry() โ€” these test whether the system supports the respective operation and whether the calling user is allowed to execute it. vibe check central ๐Ÿ”ฎ

they return one of: "na", "yes", "no", "challenge", "inhibited", "inhibitor-blocked", and "challenge-inhibitor-blocked". here's the breakdown, because these matter:

  • "na" โ€” the operation is not available because hardware, kernel, or drivers do not support it. ๐Ÿ’€
  • "yes" โ€” the operation is supported and the user may execute the operation without further authentication โœ…
  • "no" โ€” the operation is available but the user is not allowed to execute it ๐Ÿšซ
  • "challenge" โ€” the operation is available but only after authorization ๐Ÿ”
  • "inhibited" โ€” the operation is normally available without authorization but is currently inhibited. the operation is available only if inhibitors are ignored and after authorization ๐Ÿ™ˆ
  • "inhibitor-blocked" โ€” the operation is normally available without authorization but is currently inhibited. while the inhibitor remains active, the user is not allowed to execute the operation โœ‹
  • "challenge-inhibitor-blocked" โ€” similar to the above: the operation is normally available after authorization but a held inhibitor disallows the user from executing the operation ๐Ÿ˜ค

Okay so ScheduleShutdown() is the โœจplanning girlieโœจ of the shutdown world โ€” it schedules a shutdown operation of type at time usec, where usec is in microseconds since the UNIX epoch ๐Ÿ•ฐ๏ธ. OR, plot twist, if usec is UINT64_MAX and a maintenance window is configured, systemd-logind will just use the next time of the maintenance window instead ๐Ÿ’…. And type can be one of "poweroff", "dry-poweroff", "reboot", "dry-reboot", "halt", and "dry-halt" โ€” and bestie, the "dry-" variants do not actually execute the shutdown action, they're the dress rehearsal version ๐ŸŽญ.

CancelScheduledShutdown() does exactly what it says on the tin: it cancels a scheduled shutdown ๐Ÿ™…โ€โ™€๏ธ. The output parameter cancelled is true if a shutdown operation was actually scheduled, and false if there was nothing to cancel (ghosted, we love to see it).

๐Ÿšจ IMPORTANT CAVEAT BESTIE ๐Ÿšจ Note that usec is a lower bound only: the shutdown operation is executed as soon as possible, but not before the specified time. A timestamp in the past is not an error โ€” it simply means the operation is executed immediately. This is important, since a request to shut down immediately, or a very short time into the future, typically already refers to the past by the time it is processed. Time is fake and the computer is always slightly late to its own party ๐Ÿ˜ญ.

SetWallMessage() sets the wall message โ€” aka the message that will be sent out to all terminals and stored in a utmp(5) record โ€” for a subsequent scheduled shutdown operation ๐Ÿ“ข. The parameter wall_message specifies the shutdown reason (and it may be empty, no thoughts head empty is valid) which will be included in the shutdown message. The parameter enable specifies whether to print a wall message on shutdown at all. It's giving "leave a note before you go" energy ๐ŸŽ€.

Inhibit() creates an inhibition lock, and she takes four parameters: what, who, why, and mode ๐Ÿซถ.

  • what โ€” one or more of "shutdown", "sleep", "idle", "handle-power-key", "handle-suspend-key", "handle-hibernate-key", "handle-lid-switch", separated by colons, for inhibiting poweroff/reboot, suspend/hibernate, the automatic idle logic, or hardware key handling ๐Ÿ”’
  • who โ€” should be a short human-readable string identifying the application taking the lock (say your name, main character ๐Ÿ’…)
  • why โ€” should be a short human-readable string identifying the reason why the lock is taken
  • mode โ€” either "block" or "delay", which encodes whether the inhibit shall be consider mandatory or whether it should just delay the operation to a certain maximum time, while the "block-weak" and variants will create an inhibitor that is automatically ignored in some circumstances ๐Ÿ‘€

The method returns a file descriptor, and the lock is released the moment this file descriptor and all its duplicates are closed ๐Ÿšช. For more information on the inhibition logic see Inhibitor Locks[2].


๐Ÿฆ‹ Signals ๐Ÿฆ‹

Whenever the inhibition state or idle hint changes, PropertyChanged signals are sent out to clients which have subscribed ๐Ÿ“ฌ. (If you didn't subscribe, don't be nosy.)

The SecureAttentionKey() signal is sent when the user presses Ctrl+Alt+Shift+Esc to request the login manager to display the greeter, for instance in the case of a deadlocked compositor ๐Ÿ’€. It's the emergency "hello?? anyone there??" button and honestly iconic.

The SessionNew(), SessionRemoved(), UserNew(), UserRemoved(), SeatNew(), and SeatRemoved() signals are sent each time a session is created or removed, a user logs in or out, or a seat is added or removed ๐ŸŒธ. They each contain the ID of the object plus the object path โ€” so like, receipts, but for state changes ๐Ÿงพ.

The PrepareForShutdown(), PrepareForShutdownWithMetadata(), and PrepareForSleep() signals are sent right before (with the argument "true") or after (with the argument "false") the system goes down for reboot/poweroff and suspend/hibernate, respectively ๐Ÿ˜ด. This may be used by applications to save data on disk, release memory, or do other jobs that should be done shortly before shutdown/sleep, in conjunction with delay inhibitor locks. After completion of this work they should release their inhibition locks in order to not delay the operation any further โณ. For more information see Inhibitor Locks[2]. The PrepareForShutdownWithMetadata() signal additionally sends a list of key/value pair metadata fields. Currently it sends a type string which defines the type of shutdown. The type can be one of "power-off", "reboot", "halt", "kexec" or "soft-reboot". This signal is sent first, followed by PrepareForShutdown() (for backward compatibility) ๐Ÿ‘‘.


๐Ÿ’– Properties ๐Ÿ’–

Most properties simply reflect the configuration, see logind.conf(5) ๐Ÿ“„. This includes: NAutoVTs, KillOnlyUsers, KillExcludeUsers, KillUserProcesses, IdleAction, InhibitDelayMaxUSec, InhibitorsMax, UserStopDelayUSec, HandlePowerKey, HandleSuspendKey, HandleHibernateKey, HandleLidSwitch, HandleLidSwitchExternalPower, HandleLidSwitchDocked, IdleActionUSec, HoldoffTimeoutUSec, RemoveIPC, RuntimeDirectorySize, RuntimeDirectoryInodesMax, InhibitorsMax, and SessionsMax. Yes, InhibitorsMax really is in that list twice โ€” I don't make the rules, I just keep every single detail, and I said what I said ๐Ÿ’โ€โ™€๏ธโœจ.

The IdleHint property reflects the idle hint state of the system. If the system is idle it might get into automatic suspend or shutdown depending on the configuration ๐Ÿ˜ด.

IdleSinceHint and IdleSinceHintMonotonic encode the timestamps of the last change of the idle hint boolean, in CLOCK_REALTIME and CLOCK_MONOTONIC timestamps, respectively, in microseconds since the epoch ๐Ÿ•ฐ๏ธ.

The BlockInhibited, BlockWeakInhibited, and DelayInhibited properties encode the currently active locks of the respective modes ๐Ÿ”. They are colon separated lists of "shutdown", "sleep", and "idle" (see above).

NCurrentSessions and NCurrentInhibitors contain the number of currently registered sessions and inhibitors ๐Ÿ”ข.

The BootLoaderEntries property contains a list of boot loader entries. This includes boot loader entries defined in configuration and any additional loader entries reported by the boot loader. See systemd-boot(7) for more information ๐Ÿฅพ.

The PreparingForShutdown and PreparingForSleep boolean properties are true during the interval between the two PrepareForShutdown() and PrepareForSleep() signals respectively โฑ๏ธ. The PreparingForShutdownWithMetadata property provides a list of key/value pair metadata fields. Currently it lists a preparing boolean that corresponds to the PreparingForShutdown property, and, if a shutdown is being prepared, it will also contain a type string which defines the type of shutdown. The type can be one of "power-off", "reboot", "halt", "kexec" or "soft-reboot". Note that these properties do not send out PropertyChanged signals ๐Ÿคซ.

The RebootParameter property shows the value set with the SetRebootParameter() method described above.

ScheduledShutdown shows the value pair set with the ScheduleShutdown() method described above ๐Ÿ“….

RebootToFirmwareSetup, RebootToBootLoaderMenu, and RebootToBootLoaderEntry are true when the respective post-reboot operation was selected with SetRebootToFirmwareSetup(), SetRebootToBootLoaderMenu(), or SetRebootToBootLoaderEntry() โœ….

The WallMessage and EnableWallMessages properties reflect the shutdown reason and wall message enablement switch which can be set with the SetWallMessage() method described above ๐Ÿ“ฃ.

Docked is true if the machine is connected to a dock. LidClosed is true when the lid (of a laptop) is closed. OnExternalPower is true when the machine is connected to an external power supply ๐Ÿ”Œ. Physical form factor lore, we love her.


๐Ÿ”ฅ Security ๐Ÿ”ฅ

A number of operations are protected via the polkit privilege system, so bestie, some of these need a permission slip signed by auth ๐Ÿ‘ฎโ€โ™€๏ธ.

  • SetUserLinger() requires the org.freedesktop.login1.set-user-linger privilege.
  • AttachDevice() requires org.freedesktop.login1.attach-device and FlushDevices() requires org.freedesktop.login1.flush-devices.
  • PowerOff(), Reboot(), Halt(), Suspend(), Hibernate() require org.freedesktop.login1.power-off, org.freedesktop.login1.power-off-multiple-sessions, org.freedesktop.login1.power-off-ignore-inhibit, org.freedesktop.login1.reboot, org.freedesktop.login1.reboot-multiple-sessions, org.freedesktop.login1.reboot-ignore-inhibit, org.freedesktop.login1.halt, org.freedesktop.login1.halt-multiple-sessions, org.freedesktop.login1.halt-ignore-inhibit, org.freedesktop.login1.suspend, org.freedesktop.login1.suspend-multiple-sessions, org.freedesktop.login1.suspend-ignore-inhibit, org.freedesktop.login1.hibernate, org.freedesktop.login1.hibernate-multiple-sessions, org.freedesktop.login1.hibernate-ignore-inhibit, respectively depending on whether there are other sessions around or active inhibits are present.

HybridSleep() and SuspendThenHibernate() use the same privileges as Hibernate(). Sleep() uses the inhibits of the auto-selected sleep operation ๐Ÿ’ค. SetRebootParameter() requires org.freedesktop.login1.set-reboot-parameter.

SetRebootToFirmwareSetup() requires org.freedesktop.login1.set-reboot-to-firmware-setup. SetRebootToBootLoaderMenu() requires org.freedesktop.login1.set-reboot-to-boot-loader-menu. SetRebootToBootLoaderEntry() requires org.freedesktop.login1.set-reboot-to-boot-loader-entry โญ.

ScheduleShutdown() and CancelScheduledShutdown() require the same privileges (listed above) as the immediate poweroff/reboot/halt operations. Same bouncer, different door ๐Ÿ’….

Inhibit() is protected via one of org.freedesktop.login1.inhibit-block-shutdown, org.freedesktop.login1.inhibit-delay-shutdown, org.freedesktop.login1.inhibit-block-sleep, org.freedesktop.login1.inhibit-delay-sleep, org.freedesktop.login1.inhibit-block-idle, org.freedesktop.login1.inhibit-handle-power-key, org.freedesktop.login1.inhibit-handle-suspend-key, org.freedesktop.login1.inhibit-handle-hibernate-key, org.freedesktop.login1.inhibit-handle-lid-switch depending on the lock type and mode taken ๐Ÿ”.

The interactive boolean parameters can be used to control whether polkit should interactively ask the user for authentication credentials if required ๐Ÿ™‹โ€โ™€๏ธ. It's giving "the app is politely knocking on your door for a password" energy.

โœจ SEAT OBJECTS โœจ

Okay bestie, seat time ๐Ÿ’บโœจ A "seat" is like... the whole physical setup someone's sitting at โ€” monitor, keyboard, mouse, all of it. Here's what the D-Bus interface looks like:

node /org/freedesktop/login1/seat/seat0 {
  interface org.freedesktop.login1.Seat {
    methods:
      Terminate();
      ActivateSession(in  s session_id);
      SwitchTo(in  u vtnr);
      SwitchToNext();
      SwitchToPrevious();
    properties:
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s Id = '...';
      readonly (so) ActiveSession = ...;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly b CanTTY = ...;
      readonly b CanGraphical = ...;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
      readonly a(so) Sessions = [...];
      readonly b IdleHint = ...;
      readonly t IdleSinceHint = ...;
      readonly t IdleSinceHintMonotonic = ...;
  };
  interface org.freedesktop.DBus.Peer { ... };
  interface org.freedesktop.DBus.Introspectable { ... };
  interface org.freedesktop.DBus.Properties { ... };
};

๐ŸŒธ Methods ๐ŸŒธ

  • Terminate() and ActivateSession() โ€” these do the exact same thing as TerminateSeat() and ActivationSessionOnSeat() on the Manager object, just chillin' here on the Seat object instead. Same energy, different address ๐Ÿ’…
  • SwitchTo() โ€” switches to the session on the virtual terminal vtnr. Like teleporting to a specific TTY.
  • SwitchToNext() and SwitchToPrevious() โ€” switch to, respectively, the next and previous sessions on the seat, in the order of virtual terminals. And here's the lil plot twist: if there is no active session, they switch to, respectively, the first and last session on the seat instead. So they always land somewhere, periodt ๐ŸŽฏ

๐Ÿฆ‹ Signals ๐Ÿฆ‹

Whenever ActiveSession, Sessions, CanGraphical, CanTTY, or the idle state changes, PropertyChanged signals get sent out to clients which have subscribed. Like, if you're listening, you'll hear about it bestie ๐Ÿ“ฃ

โš ๏ธ Important: signals are only emitted on objects referencing a specific seat ID, not on the /org/freedesktop/login1/seat/self or /org/freedesktop/login1/seat/auto convenience objects, because those can only be dereferenced relative to a method caller. So don't be surprised when those ones stay silent, it's giving on purpose ๐Ÿ™ˆ

๐ŸŽ€ Properties ๐ŸŽ€

  • The Id property encodes the ID of the seat. That's it, that's the whole vibe.
  • ActiveSession encodes the currently active session if there is one. It's a structure consisting of the session id and the object path. Cute lil pair ๐Ÿซถ
  • CanTTY encodes whether the session is suitable for text logins, and CanGraphical whether it's suitable for graphical sessions. Vibe check on what kind of session this seat can host.
  • The Sessions property is an array of all current sessions of this seat, each encoded in a structure consisting of the ID and the object path. The whole squad, listed out ๐ŸŒˆ
  • The IdleHint, IdleSinceHint, and IdleSinceHintMonotonic properties encode the idle state, similarly to the ones exposed on the Manager object, but specific for this seat. Same idea, smaller scope, iykyk.

๐Ÿ’œ USER OBJECTS ๐Ÿ’œ

Now we're talking about the users themselves. Here's the interface shape:

node /org/freedesktop/login1/user/_1000 {
  interface org.freedesktop.login1.User {
    methods:
      Terminate();
      Kill(in  i signal_number);
    properties:
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly u UID = ...;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly u GID = ...;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s Name = '...';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly t Timestamp = ...;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly t TimestampMonotonic = ...;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s RuntimePath = '...';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s Service = '...';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s Slice = '...';
      readonly (so) Display = ...;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
      readonly s State = '...';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
      readonly a(so) Sessions = [...];
      readonly b IdleHint = ...;
      readonly t IdleSinceHint = ...;
      readonly t IdleSinceHintMonotonic = ...;
      readonly b Linger = ...;
  };
  interface org.freedesktop.DBus.Peer { ... };
  interface org.freedesktop.DBus.Introspectable { ... };
  interface org.freedesktop.DBus.Properties { ... };
};

๐ŸŒŸ Methods ๐ŸŒŸ

  • Terminate() and Kill() โ€” they work just like the TerminateUser() and KillUser() methods on the manager object. Same behavior, just accessed through the user object directly. Easy ๐Ÿ’…

โœจ Signals โœจ

Whenever Sessions or the idle state changes, PropertyChanged signals are sent out to clients which have subscribed. Stay tuned for updates ๐Ÿ“ก

โš ๏ธ Just like with seats: signals are only emitted on objects referencing a specific UID, not on the /org/freedesktop/login1/user/self convenience object, because self can only be dereferenced relative to a method caller. So self stays quiet, no cap ๐Ÿ™ˆ

๐Ÿ“ Properties ๐Ÿ“

  • The UID and GID properties encode the Unix UID and primary GID of the user. The classic identifiers, iconic fr.
  • The Name property encodes the user name. The name name, the one and only.
  • Timestamp and TimestampMonotonic encode the login time of the user in microseconds since the epoch, in the CLOCK_REALTIME and CLOCK_MONOTONIC clocks, respectively. So one's the wall-clock vibe and one's the "how long has the system been up" vibe. Both micro, both since epoch โฐ
  • RuntimePath encodes the runtime path of the user, i.e. $XDG_RUNTIME_DIR. For details see the XDG Basedir Specification[3]. That's their personal lil scratch space.
  • Service contains the unit name of the user systemd service of this user. Each logged in user is assigned a user service that runs a user systemd instance. This is usually an instance of user@.service. So every user gets their own mini systemd, main character energy ๐Ÿ‘‘
  • Slice contains the unit name of the user systemd slice of this user. Each logged in user gets a private slice. Your own little cgroup neighborhood ๐ŸŒธ
  • Display encodes which graphical session should be used as the primary UI display for the user. It is a structure encoding the session ID and the object path of the session to use. Basically "this is the screen you should actually be looking at" ๐Ÿ–ฅ๏ธ
  • State encodes the user state and is one of "offline", "lingering", "online", "active", or "closing". See sd_uid_get_state(3) for more information about the states. So if you need the deets on those states, that's where to look, bestie ๐Ÿ“–
  • Sessions is an array of structures encoding all current sessions of the user. Each structure consists of the ID and object path. All their sessions, all lined up ๐Ÿฆ‹
  • The IdleHint, IdleSinceHint, and IdleSinceHintMonotonic properties encode the idle hint state of the user, similarly to the Manager's properties, but specific for this user. Same trio, but personalized.
  • The Linger property shows whether lingering is enabled for this user. Lingering = they stick around even when not logged in. Slay, staying power ๐Ÿ’œ

๐Ÿ‘‘ SESSION OBJECTS ๐Ÿ‘‘

The main event, the sessions themselves. Here's the interface:

node /org/freedesktop/login1/session/1 {
  interface org.freedesktop.login1.Session {
    methods:
      Terminate();
      Activate();
      Lock();
      Unlock();
      SetIdleHint(in  b idle);
      SetLockedHint(in  b locked);
      Kill(in  s whom,
           in  i signal_number);
      TakeControl(in  b force);
      ReleaseControl();
      SetType(in  s type);
      SetClass(in  s class);
      SetDisplay(in  s display);
      SetTTY(in  h tty_fd);
      TakeDevice(in  u major,
                 in  u minor,
                 out h fd,
                 out b inactive);
      ReleaseDevice(in  u major,
                    in  u minor);
      PauseDeviceComplete(in  u major,
                          in  u minor);
      SetBrightness(in  s subsystem,
                    in  s name,
                    in  u brightness);
    signals:
      PauseDevice(u major,
                  u minor,
                  s type);
      ResumeDevice(u major,
                   u minor,
                   h fd);
      Lock();
      Unlock();
    properties:
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s Id = '...';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly (uo) User = ...;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s Name = '...';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly t Timestamp = ...;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly t TimestampMonotonic = ...;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly u VTNr = ...;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly (so) Seat = ...;
      readonly s TTY = '...';
      readonly s Display = '...';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly b Remote = ...;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s RemoteHost = '...';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s RemoteUser = '...';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly as ExtraDeviceAccess = ['...', ...];
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s Service = '...';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s Desktop = '...';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly s Scope = '...';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly u Leader = ...;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly t LeaderPIDFDId = ...;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly u Audit = ...;
      readonly s Type = '...';
      readonly s Class = '...';
      readonly b Active = ...;
      readonly s State = '...';
      readonly b IdleHint = ...;
      readonly t IdleSinceHint = ...;
      readonly t IdleSinceHintMonotonic = ...;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly b CanIdle = ...;
      @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
      readonly b CanLock = ...;
      readonly b LockedHint = ...;
  };
  interface org.freedesktop.DBus.Peer { ... };
  interface org.freedesktop.DBus.Introspectable { ... };
  interface org.freedesktop.DBus.Properties { ... };
};

๐Ÿฆ‹ Methods ๐Ÿฆ‹

  • Terminate(), Activate(), Lock(), Unlock(), and Kill() โ€” these work similarly to the respective calls on the Manager object. Same names, same vibes, just living on the session now ๐Ÿ’…
  • SetIdleHint() โ€” this one is called by the session object to update the idle state of the session whenever it changes. It's the session's way of raising its hand and going "hey, I'm idle now" ๐Ÿ™‹โ™€๏ธ

to be continued, bestieโ€ฆ the session methods and properties are coming right up ๐Ÿ’–

  • TakeControl() โ€” bestie, this is how a process takes exclusive managed device access-control for that session. Only one D-Bus connection can be a controller for a given session at any time, periodt. If the force argument is set (root only), an existing controller gets kicked out and replaced ๐Ÿ’…. Otherwise this method just fails if there's already a controller. Heads up though: this method is limited to D-Bus users with the effective UID set to the user of the session, or root.
  • ReleaseControl() โ€” drops control of a given session. Closing the D-Bus connection implicitly releases control too, no cap. See TakeControl() for more info. This method also releases all devices for which the controller requested ownership via TakeDevice(). Clean exit, we love to see it โœจ
  • SetType() โ€” lets you change the type of the session dynamically, main character energy. It can only be called by the session's current controller, and if TakeControl() hasn't been called, this method will fail. Also โ€” and this is the important bit โ€” the session type gets reset to its original value once control is released, whether that's by calling ReleaseControl() or by closing the D-Bus connection. This is on purpose: it helps prevent a session from ending up in an inconsistent state, like if the controller just crashes ๐Ÿ˜ญ. The only argument type is the new session type.
  • SetClass() โ€” lets the caller change the class of the session dynamically. It may only be called by the session's owning user. Currently this call may be exclusively used to change the class from "user-incomplete" to "user". The call is synchronous, and will return only once the user's service manager has successfully been started, if necessary. The only argument type is the new session type.
  • SetDisplay() โ€” lets the display name of the graphical session be changed. Super useful if the display server is started as part of the session. It can only be called by the session's current controller, and if TakeControl() hasn't been called, this method will fail. The only argument display is the new display name.
  • SetTTY() โ€” lets the device name of the session be changed. Useful when the tty device is only known after authentication (iykyk). It can only be called by the session's current controller, and if TakeControl() hasn't been called, this method will fail. The only argument tty_fd is a file handle to the new tty device.
  • TakeDevice() โ€” lets a session controller get a file descriptor for a specific device ๐Ÿ‘‘. Pass in the major and minor numbers of the character device and systemd-logind will return a file descriptor for the device. Only a limited set of device-types is currently supported (but it may be extended, so stay tuned). systemd-logind automatically mutes the file descriptor if the session is inactive and resumes it once the session is activated again. This guarantees a session can only access session devices if the session is active. Note that this revoke/resume mechanism is asynchronous and may happen at any given time โฐ. This only works on devices that are attached to the seat of the given session. A process is not required to have direct access to the device node. systemd-logind only requires you to be the active session controller (see TakeControl()). Also note that any device can only be requested once โ€” as long as you don't release it, further TakeDevice() calls will fail.
  • ReleaseDevice() โ€” releases a device again (see TakeDevice()). This is also implicitly done by ReleaseControl() or when closing the D-Bus connection.
  • PauseDeviceComplete() โ€” lets a session controller synchronously pause a device after receiving a PauseDevice("pause") signal. Forced signals (or after an internal timeout) are automatically completed by systemd-logind asynchronously.
  • SetLockedHint() โ€” may be used to set the "locked hint" to locked, i.e. the info about whether the session is locked ๐Ÿ”’. This is intended to be used by the desktop environment to tell systemd-logind when the session is locked and unlocked.
  • SetBrightness() โ€” may be used to set the display brightness โœจ. This is intended to be used by the desktop environment and allows unprivileged programs to access hardware settings in a controlled way. The subsystem parameter specifies a kernel subsystem, either "backlight" or "leds". The name parameter specifies a device name under the specified subsystem. The brightness parameter specifies the brightness. The range is defined by individual drivers, see /sys/class/subsystem/name/max_brightness.

๐ŸŒˆ Signals ๐ŸŒˆ

The active session controller exclusively gets PauseDevice() and ResumeDevice() events for any device it requested via TakeDevice(). They notify the controller whenever a device is paused or resumed. A device is never resumed if its session is inactive. Also note that PauseDevice() signals are sent before the PropertyChanged signal for the Active state. The inverse is true for ResumeDevice(). A device may remain paused for unknown reasons even though the Session is active ๐Ÿคทโ™€๏ธ.

A PauseDevice() signal carries the major and minor numbers and a string describing the type as arguments.

  • force means the device was already paused by systemd-logind and the signal is only an asynchronous notification.
  • pause means systemd-logind grants you a limited amount of time to pause the device. You must respond to this via PauseDeviceComplete(). This synchronous pausing mechanism is used for backwards-compatibility to VTs and systemd-logind is free to not make use of it. It is also free to send a forced PauseDevice() if you do not respond in a timely manner (or for any other reason ๐Ÿ˜ญ).
  • gone means the device was unplugged from the system and you will no longer get any notifications about it. There is no need to call ReleaseDevice(). You may call TakeDevice() again if a new device is assigned the major+minor combination.

ResumeDevice() is sent whenever a session is active and a device is resumed. It carries the major/minor numbers as arguments and provides a new open file descriptor. You should switch to the new descriptor and close the old one ๐Ÿ”„. They are not guaranteed to have the same underlying open file descriptor in the kernel (except for a limited set of device types).

Whenever Active or the idle state changes, PropertyChanged signals are sent out to clients which have subscribed ๐Ÿ“ฌ.

Lock()/Unlock() is sent when the session is asked to be screen-locked/unlocked. A session manager of the session should listen to this signal and act accordingly. This signal is sent out as a result of the Lock() and Unlock() methods, respectively.

Signals are only emitted on objects referencing a specific session ID โ€” not on the /org/freedesktop/login1/session/self or /org/freedesktop/login1/session/auto convenience objects, as they can only be dereferenced relative to a method caller. Important bestie, don't get caught out ๐Ÿ’€

๐Ÿ’– Properties ๐Ÿ’–

  • Id โ€” encodes the session ID.
  • User โ€” encodes the user ID of the user this session belongs to. This is a structure consisting of the Unix UID and the object path.
  • Name โ€” encodes the user name.
  • Timestamp and TimestampMonotonic โ€” encode the microseconds since the epoch when the session was created, in CLOCK_REALTIME or CLOCK_MONOTONIC, respectively.
  • VTNr โ€” encodes the virtual terminal number of the session if there is any, 0 otherwise.
  • Seat โ€” encodes the seat this session belongs to if there is any. This is a structure consisting of the ID and the seat object path.
  • TTY โ€” encodes the kernel TTY path of the session if this is a text login. If not, this is an empty string.
  • Display โ€” encodes the X11 display name if this is a graphical login. If not, this is an empty string.
  • Remote โ€” encodes whether the session is local or remote.
  • RemoteHost and RemoteUser โ€” encode the remote host and user if this is a remote session, or an empty string otherwise.
  • ExtraDeviceAccess โ€” encodes the set of additional hardware devices that the session is granted access to. For every "ID" in the list, the session is granted access to all devices tagged with "xaccess-ID" in udev.
  • Service โ€” encodes the PAM service name that registered the session.
  • Desktop โ€” describes the desktop environment running in the session (if known).
  • Scope โ€” contains the systemd scope unit name of this session.
  • Leader โ€” encodes the PID of the process that registered the session.
  • LeaderPIDFDId โ€” encodes the Linux pidfd inode ID of the process that registered the session.
  • Audit โ€” encodes the Kernel Audit session ID of the session if auditing is available.
  • Type โ€” encodes the session type. It's one of "unspecified" (for cron PAM sessions and suchlike), "tty" (for text logins), "web" (for web-based logins), or "x11"/"mir"/"wayland" (for graphical logins).
  • Class โ€” encodes the session class. It's one of "user" (for normal user sessions), "greeter" (for display manager pseudo-sessions), or "lock-screen" (for display lock screens).
  • Active โ€” a boolean that is true if the session is active, i.e. currently in the foreground. This field is semi-redundant due to State.
  • State โ€” encodes the session state and one of "online", "active", or "closing". See sd_session_get_state(3) for more information about the states.
  • IdleHint, IdleSinceHint, and IdleSinceHintMonotonic โ€” encapsulate the idle hint state of this session, similarly to how the respective properties on the manager object do it for the whole system.
  • LockedHint โ€” shows the locked hint state of this session, as set by the SetLockedHint() method described above.
  • CanIdle โ€” indicates whether the session supports the idle hint concept. Similarly, CanLock indicates whether the session supports the screen lock concept.

๐ŸŽ€ EXAMPLES ๐ŸŽ€

Example 1. Introspect the logind manager on the bus

$ gdbus introspect --system --dest org.freedesktop.login1 \
  --object-path /org/freedesktop/login1

or

$ busctl introspect org.freedesktop.login1 /org/freedesktop/login1

Example 2. Introspect the default seat on the bus

$ gdbus introspect --system --dest org.freedesktop.login1 \
 --object-path /org/freedesktop/login1/seat/seat0

or

$ busctl introspect org.freedesktop.login1 /org/freedesktop/login1/seat/seat0

Seat "seat0" is the default seat, so it'll be present unless local configuration is made to reassign all devices to a different seat. The list of seats and users can be acquired with loginctl list-sessions.

Example 3. Introspect a single user on the bus

$ gdbus introspect --system --dest org.freedesktop.login1 \
  --object-path /org/freedesktop/login1/user/_1000

or

$ busctl introspect org.freedesktop.login1 /org/freedesktop/login1/user/_1000

Example 4. Introspect org.freedesktop.login1.Session on the bus

$ gdbus introspect --system --dest org.freedesktop.login1 \
  --object-path /org/freedesktop/login1/session/45

or

$ busctl introspect org.freedesktop.login1 /org/freedesktop/login1/session/45

โญ VERSIONING โญ

These D-Bus interfaces follow the usual interface versioning guidelines[4]. Slay, that's the whole thing ๐Ÿซถ

๐Ÿ•ฐ๏ธ HISTORY โœจ

ok so like, this page has lore ๐Ÿ“œ and you deserve to know it. everything here is about when stuff showed up, so if you're on an older systemd bestie and something's giving "unknown method", this is your receipts ๐Ÿงพ


๐ŸŒŸ The Manager Object

  • HandlePowerKeyLongPress, HandleRebootKey, HandleRebootKeyLongPress, HandleSuspendKeyLongPress, and HandleHibernateKeyLongPress โ€” these cuties โœจ were added in version 251. yes, all five of them, they showed up to the party together ๐Ÿ’…
  • StopIdleSessionUSec โ€” added in version 252 ๐ŸŽ€
  • PrepareForShutdownWithMetadata() and CreateSessionWithPIDFD() โ€” added in version 255 ๐Ÿฆ‹
  • Sleep(), CanSleep(), SleepOperation, and ListSessionsEx() โ€” added in version 256 ๐Ÿ˜ดโœจ
  • HandleSecureAttentionKey, SecureAttentionKey(), PreparingForShutdownWithMetadata, DesignatedMaintenanceTime, CanIdle, CanLock, and BlockWeakInhibited โ€” added in version 257 ๐Ÿ”ฅ (that's a stacked release ngl, 257 ate fr fr)

๐ŸŒธ Session Objects

  • SetDisplay() โ€” added in version 252 ๐Ÿ–ฅ๏ธ
  • SetTTY() โ€” added in version 254 โŒจ๏ธ
  • SetClass() โ€” added in version 256 ๐Ÿ’–
  • LeaderPIDFDId โ€” added in version 258 ๐Ÿงš
  • ExtraDeviceAccess โ€” added in version 260 ๐Ÿ‘‘ (the newest baby on the block)

๐Ÿ‘€ SEE ALSO

go read those, they're the rest of the friend group ๐Ÿซถ


๐Ÿ“ NOTES

  1. polkit
https://www.freedesktop.org/software/polkit/docs/latest/
  1. Inhibitor Locks
https://systemd.io/INHIBITOR_LOCKS
  1. XDG Basedir Specification
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
  1. the usual interface versioning guidelines
https://0pointer.de/blog/projects/versioning-dbus.html

and that's the whole page bestie!! ๐ŸŽ‰ you made it to the end, main character energy fr fr ๐Ÿ’œ this whole thing is the ORG.FREEDESKTOP.LOGIN1(5) manual page as it ships with systemd 262.1 โ€” that's the source and version stamping the bottom of the original, and the date lives down there too on the real thing, right next to the page name. go log in, log out, and slay ๐Ÿ’…โœจ๐ŸŒธ

๐Ÿ“ฆ where this page comes from
  • arch rolling: systemd 262.1-1 ยท LGPL-2.1-or-later AND CC0-1.0 AND GPL-2.0-or-later AND MIT-0
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms