diff --git a/man/org.freedesktop.login1.xml b/man/org.freedesktop.login1.xml
index bf00800cef..1008c59a32 100644
--- a/man/org.freedesktop.login1.xml
+++ b/man/org.freedesktop.login1.xml
@@ -256,6 +256,8 @@ node /org/freedesktop/login1 {
@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("false")
@@ -526,6 +528,8 @@ node /org/freedesktop/login1 {
+
+
@@ -815,8 +819,14 @@ node /org/freedesktop/login1 {
The PreparingForShutdown and PreparingForSleep boolean
properties are true during the interval between the two PrepareForShutdown() and
- PrepareForSleep() signals respectively. Note that these properties do not
- send out PropertyChanged signals.
+ 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.
@@ -1609,7 +1619,8 @@ node /org/freedesktop/login1/session/1 {
SleepOperation,
DesignatedMaintenanceTime, and
ListSessionsEx() were added in version 256.
- HandleSecureAttentionKey, and
+ HandleSecureAttentionKey,
+ PreparingForShutdownWithMetadata, and
SecureAttentionKey() were added in version 257.
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 98f14bd0b1..2f60f15131 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -341,6 +341,35 @@ static int property_get_preparing(
return sd_bus_message_append(reply, "b", b);
}
+static int property_get_preparing_shutdown_with_metadata(
+ sd_bus *bus,
+ const char *path,
+ const char *interface,
+ const char *property,
+ sd_bus_message *reply,
+ void *userdata,
+ sd_bus_error *error) {
+
+ Manager *m = ASSERT_PTR(userdata);
+
+ assert(bus);
+ assert(reply);
+
+ if (!m->delayed_action || !(m->delayed_action->inhibit_what & INHIBIT_SHUTDOWN))
+ return sd_bus_message_append(reply, "a{sv}", 1, "preparing", "b", false);
+
+ return sd_bus_message_append(
+ reply,
+ "a{sv}",
+ 2,
+ "preparing",
+ "b",
+ true,
+ "type",
+ "s",
+ handle_action_to_string(m->delayed_action->handle));
+}
+
static int property_get_sleep_operations(
sd_bus *bus,
const char *path,
@@ -3718,6 +3747,7 @@ static const sd_bus_vtable manager_vtable[] = {
SD_BUS_PROPERTY("IdleAction", "s", property_get_handle_action, offsetof(Manager, idle_action), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("IdleActionUSec", "t", NULL, offsetof(Manager, idle_action_usec), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("PreparingForShutdown", "b", property_get_preparing, 0, 0),
+ SD_BUS_PROPERTY("PreparingForShutdownWithMetadata", "a{sv}", property_get_preparing_shutdown_with_metadata, 0, 0),
SD_BUS_PROPERTY("PreparingForSleep", "b", property_get_preparing, 0, 0),
SD_BUS_PROPERTY("ScheduledShutdown", "(st)", property_get_scheduled_shutdown, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("DesignatedMaintenanceTime", "s", property_get_maintenance_time, 0, 0),
diff --git a/test/units/TEST-82-SOFTREBOOT.sh b/test/units/TEST-82-SOFTREBOOT.sh
index 9f3d4066c3..eb6fb37561 100755
--- a/test/units/TEST-82-SOFTREBOOT.sh
+++ b/test/units/TEST-82-SOFTREBOOT.sh
@@ -273,6 +273,10 @@ EOF
touch /run/TEST-82-SOFTREBOOT.touch
systemctl --no-block --check-inhibitors=yes soft-reboot
+ # Ensure the property works too
+ type="$(busctl --json=short get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager PreparingForShutdownWithMetadata | jq -r '.data.type.data')"
+ test "$type" = "soft-reboot"
+
# Now block until the soft-boot killing spree kills us
exec sleep infinity
fi