From be9357c67619550e12a3c959c33ebaae5b031617 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 17 Jun 2020 17:44:12 +0200 Subject: daemon: Add LowPowerMode toggle Closes: #102 --- dbus/org.freedesktop.UPower.xml | 43 +++++++++++++++++++++++++++++++++++++++++ src/up-daemon.c | 15 ++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/dbus/org.freedesktop.UPower.xml b/dbus/org.freedesktop.UPower.xml index cdeb2b8..2f7baf2 100644 --- a/dbus/org.freedesktop.UPower.xml +++ b/dbus/org.freedesktop.UPower.xml @@ -132,6 +132,32 @@ method return sender=:1.386 -> dest=:1.451 reply_serial=2 + + + + Whether to enable the low-power mode. + + + + + + When the system's power supply is critical (critically low batteries or UPS), + the system will take this action. Possible values are: + + + HybridSleep + + + Hibernate + + + PowerOff + + + + + + @@ -199,6 +225,23 @@ method return sender=:1.386 -> dest=:1.451 reply_serial=2 + + + + + Whether the system should be in low-power mode. This property does + not actually control anything of its own, but applications and system + components are expected to try and reduce their power consumption when + the property is set to true. + + + Setting the property is possible for active seats, using the SetLowPowerMode() + method. + + + + + diff --git a/src/up-daemon.c b/src/up-daemon.c index 5263c34..c4ae939 100644 --- a/src/up-daemon.c +++ b/src/up-daemon.c @@ -431,6 +431,19 @@ up_daemon_get_display_device (UpExportedDaemon *skeleton, return TRUE; } +/** + * up_daemon_set_low_power_mode: + **/ +static gboolean +up_daemon_set_low_power_mode (UpExportedDaemon *skeleton, + GDBusMethodInvocation *invocation, + UpDaemon *daemon) +{ + //FIXME verify that this gets blocked for users that aren't at the console + up_exported_daemon_complete_set_low_power_mode (skeleton, invocation); + return TRUE; +} + /** * up_daemon_get_critical_action: **/ @@ -1108,6 +1121,8 @@ up_daemon_init (UpDaemon *daemon) G_CALLBACK (up_daemon_get_critical_action), daemon); g_signal_connect (daemon, "handle-get-display-device", G_CALLBACK (up_daemon_get_display_device), daemon); + g_signal_connect (daemon, "handle-set-low-power-mode", + G_CALLBACK (up_daemon_set_low_power_mode), daemon); } static const GDBusErrorEntry up_daemon_error_entries[] = { -- cgit v1.2.3