]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
login1: Emit NCurrentInhibitors changed events
authorAdrian Vovk <adrianvovk@gmail.com>
Tue, 20 Jan 2026 00:26:30 +0000 (19:26 -0500)
committerAdrian Vovk <adrianvovk@gmail.com>
Tue, 24 Feb 2026 01:03:07 +0000 (20:03 -0500)
Currently, there's no way for a desktop environment to detect when a
systemd inhibitor has been added or removed. This means that a desktop
environment that wishes to show current inhibitors to the user will be
either forced to poll systemd or just use stale data.

Now, the desktop can listen for changed events on NCurrentInhibitors and
call GetInhibitors() in response to that.

man/org.freedesktop.login1.xml
src/login/logind-dbus.c
src/login/logind-inhibit.c

index bc9525385933307f102163a78ff49463a3ed9292..dc80e96717724f7158bdc6ce18e2fb2644445999 100644 (file)
@@ -276,7 +276,6 @@ node /org/freedesktop/login1 {
       readonly t RuntimeDirectoryInodesMax = ...;
       @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
       readonly t InhibitorsMax = ...;
-      @org.freedesktop.DBus.Property.EmitsChangedSignal("false")
       readonly t NCurrentInhibitors = ...;
       @org.freedesktop.DBus.Property.EmitsChangedSignal("const")
       readonly t SessionsMax = ...;
index 7f7d9e70d2b529122f4d90a158cf781272a3a792..b50e69809fea01979a5a0fb2871e35898d58bdff 100644 (file)
@@ -3960,7 +3960,7 @@ static const sd_bus_vtable manager_vtable[] = {
         SD_BUS_PROPERTY("RuntimeDirectorySize", "t", NULL, offsetof(Manager, runtime_dir_size), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("RuntimeDirectoryInodesMax", "t", NULL, offsetof(Manager, runtime_dir_inodes), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("InhibitorsMax", "t", NULL, offsetof(Manager, inhibitors_max), SD_BUS_VTABLE_PROPERTY_CONST),
-        SD_BUS_PROPERTY("NCurrentInhibitors", "t", property_get_hashmap_size, offsetof(Manager, inhibitors), 0),
+        SD_BUS_PROPERTY("NCurrentInhibitors", "t", property_get_hashmap_size, offsetof(Manager, inhibitors), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
         SD_BUS_PROPERTY("SessionsMax", "t", NULL, offsetof(Manager, sessions_max), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("NCurrentSessions", "t", property_get_hashmap_size, offsetof(Manager, sessions), 0),
         SD_BUS_PROPERTY("UserTasksMax", "t", property_get_compat_user_tasks_max, 0, SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN),
index 2ef15588f289db8fdd403b319d74fe93aeeb2e66..b78d39d02d7775cefd16f250552bf284735ace8c 100644 (file)
@@ -148,13 +148,11 @@ static int inhibitor_save(Inhibitor *i) {
 }
 
 static int bus_manager_send_inhibited_change(Inhibitor *i) {
-        const char *property;
-
         assert(i);
 
-        property = IN_SET(i->mode, INHIBIT_BLOCK, INHIBIT_BLOCK_WEAK) ? "BlockInhibited" : "DelayInhibited";
-
-        return manager_send_changed(i->manager, property);
+        return manager_send_changed(i->manager,
+                                    i->mode == INHIBIT_DELAY ? "DelayInhibited" : "BlockInhibited",
+                                    "NCurrentInhibitors");
 }
 
 int inhibitor_start(Inhibitor *i) {