From c4db78fce61adaeb8894995a5777443125524a9a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 5 Apr 2022 15:50:56 +0200 Subject: [PATCH 1/3] logind: expose long press actions on D-Bus The settings and internal varables were added, but this was never exposed on the bus. Add that. Follow-up-for: a520bb665417af7aa98dcb983f3583659bbab807 Follow-up-for: #19917 --- man/org.freedesktop.login1.xml | 30 ++++++++++++++++++++++++++++++ src/login/logind-dbus.c | 5 +++++ 2 files changed, 35 insertions(+) diff --git a/man/org.freedesktop.login1.xml b/man/org.freedesktop.login1.xml index d25287b18b..8fc145d771 100644 --- a/man/org.freedesktop.login1.xml +++ b/man/org.freedesktop.login1.xml @@ -194,10 +194,20 @@ node /org/freedesktop/login1 { @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 = '...'; @@ -242,6 +252,16 @@ node /org/freedesktop/login1 { }; + + + + + + + + + + @@ -418,10 +438,20 @@ node /org/freedesktop/login1 { + + + + + + + + + + diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 1212a1ac53..a9da1e7731 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -3378,8 +3378,13 @@ static const sd_bus_vtable manager_vtable[] = { SD_BUS_PROPERTY("InhibitDelayMaxUSec", "t", NULL, offsetof(Manager, inhibit_delay_max), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("UserStopDelayUSec", "t", NULL, offsetof(Manager, user_stop_delay), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("HandlePowerKey", "s", property_get_handle_action, offsetof(Manager, handle_power_key), SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("HandlePowerKeyLongPress", "s", property_get_handle_action, offsetof(Manager, handle_power_key_long_press), SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("HandleRebootKey", "s", property_get_handle_action, offsetof(Manager, handle_reboot_key), SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("HandleRebootKeyLongPress", "s", property_get_handle_action, offsetof(Manager, handle_reboot_key_long_press), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("HandleSuspendKey", "s", property_get_handle_action, offsetof(Manager, handle_suspend_key), SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("HandleSuspendKeyLongPress", "s", property_get_handle_action, offsetof(Manager, handle_suspend_key_long_press), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("HandleHibernateKey", "s", property_get_handle_action, offsetof(Manager, handle_hibernate_key), SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("HandleHibernateKeyLongPress", "s", property_get_handle_action, offsetof(Manager, handle_hibernate_key_long_press), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("HandleLidSwitch", "s", property_get_handle_action, offsetof(Manager, handle_lid_switch), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("HandleLidSwitchExternalPower", "s", property_get_handle_action, offsetof(Manager, handle_lid_switch_ep), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("HandleLidSwitchDocked", "s", property_get_handle_action, offsetof(Manager, handle_lid_switch_docked), SD_BUS_VTABLE_PROPERTY_CONST), From acc63800bcb4065942ed414c2b1119b7d1e3a191 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 5 Apr 2022 15:52:49 +0200 Subject: [PATCH 2/3] logind: also show long press settings in default logind.conf The configuration options where added back in a520bb665417af7aa98dcb983f3583659bbab807 but this was never actually added to the default logind.conf. Follow-up-for: a520bb665417af7aa98dcb983f3583659bbab807 Follow-up-for: #19917 --- src/login/logind.conf.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/login/logind.conf.in b/src/login/logind.conf.in index 926bd6cfe9..8ec979e0e8 100644 --- a/src/login/logind.conf.in +++ b/src/login/logind.conf.in @@ -23,13 +23,16 @@ #InhibitDelayMaxSec=5 #UserStopDelaySec=10 #HandlePowerKey=poweroff +#HandlePowerKeyLongPress=ignore +#HandleRebootKey=reboot +#HandleRebootKeyLongPress=poweroff #HandleSuspendKey=suspend +#HandleSuspendKeyLongPress=hibernate #HandleHibernateKey=hibernate +#HandleHibernateKeyLongPress=ignore #HandleLidSwitch=suspend #HandleLidSwitchExternalPower=suspend #HandleLidSwitchDocked=ignore -#HandleRebootKey=reboot -#HandleRebootKeyLongPress=poweroff #PowerKeyIgnoreInhibited=no #SuspendKeyIgnoreInhibited=no #HibernateKeyIgnoreInhibited=no From 30e0343b1cac3660bcab518317ef28a7cd343375 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 5 Apr 2022 15:59:01 +0200 Subject: [PATCH 3/3] man: split an overly long paragraph in two --- man/logind.conf.xml | 69 ++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 41 deletions(-) diff --git a/man/logind.conf.xml b/man/logind.conf.xml index 3045c1b9ba..fc838abee2 100644 --- a/man/logind.conf.xml +++ b/man/logind.conf.xml @@ -205,47 +205,34 @@ HandleLidSwitchExternalPower= HandleLidSwitchDocked= - Controls how logind shall handle the - system power, reboot and sleep keys and the lid switch to trigger - actions such as system power-off, reboot or suspend. Can be one of - ignore, - poweroff, - reboot, - halt, - kexec, - suspend, - hibernate, - hybrid-sleep, - suspend-then-hibernate, - lock, and - factory-reset. - If ignore, logind will never handle these - keys. If lock, all running sessions will be - screen-locked; otherwise, the specified action will be taken - in the respective event. Only input devices with the - power-switch udev tag will be watched for - key/lid switch events. HandlePowerKey= - defaults to poweroff, HandleRebootKey= - defaults to reboot, HandleSuspendKey= - defaults to suspend, HandleHibernateKey= - defaults to hibernate, HandlePowerKeyLongPress= - defaults to ignore, HandleRebootKeyLongPress= - defaults to poweroff, HandleSuspendKeyLongPress= - defaults to hibernate, HandleHibernateKeyLongPress= - defaults to ignore. - HandleLidSwitch= defaults to - suspend. - HandleLidSwitchExternalPower= is completely - ignored by default (for backwards compatibility) — an explicit - value must be set before it will be used to determine - behaviour. HandleLidSwitchDocked= defaults - to ignore. If the system is inserted in a - docking station, or if more than one display is connected, the - action specified by HandleLidSwitchDocked= - occurs; if the system is on external power the action (if any) - specified by HandleLidSwitchExternalPower= - occurs; otherwise the HandleLidSwitch= - action occurs. + Controls how logind shall handle the system power, reboot and sleep keys and the lid + switch to trigger actions such as system power-off, reboot or suspend. Can be one of + ignore, poweroff, reboot, + halt, kexec, suspend, + hibernate, hybrid-sleep, + suspend-then-hibernate, lock, and + factory-reset. If ignore, systemd-logind + will never handle these keys. If lock, all running sessions will be screen-locked; + otherwise, the specified action will be taken in the respective event. Only input devices with the + power-switch udev tag will be watched for key/lid switch + events. + + HandlePowerKey= defaults to poweroff, + HandleRebootKey= defaults to reboot, + HandleSuspendKey= defaults to suspend, + HandleHibernateKey= defaults to hibernate, + HandlePowerKeyLongPress= defaults to ignore, + HandleRebootKeyLongPress= defaults to poweroff, + HandleSuspendKeyLongPress= defaults to hibernate, + HandleHibernateKeyLongPress= defaults to ignore. + HandleLidSwitch= defaults to suspend. + HandleLidSwitchExternalPower= is completely ignored by default (for backwards + compatibility) — an explicit value must be set before it will be used to determine + behaviour. HandleLidSwitchDocked= defaults to ignore. If the + system is inserted in a docking station, or if more than one display is connected, the action + specified by HandleLidSwitchDocked= occurs; if the system is on external power the + action (if any) specified by HandleLidSwitchExternalPower= occurs; otherwise the + HandleLidSwitch= action occurs. A different application may disable logind's handling of system power and sleep keys and the lid switch by taking a low-level inhibitor lock