summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2020-06-17 17:44:12 +0200
committerBastien Nocera <hadess@hadess.net>2020-06-17 17:44:56 +0200
commitbe9357c67619550e12a3c959c33ebaae5b031617 (patch)
tree3e756ac1ceb8024ef6a4972033bf575cb5e0c456
parent0a9c8458f272c0ca35f0b0ece08575a6fd6db4c9 (diff)
downloadupower-wip/hadess/low-power-mode.tar.gz
daemon: Add LowPowerMode togglewip/hadess/low-power-mode
Closes: #102
-rw-r--r--dbus/org.freedesktop.UPower.xml43
-rw-r--r--src/up-daemon.c15
2 files changed, 58 insertions, 0 deletions
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
</doc:doc>
</method>
+ <method name="SetLowPowerMode">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="low_power_mode" direction="in" type="b">
+ <doc:doc><doc:summary>Whether to enable the <doc:ref type="property" to="Source:LowPowerMode">low-power mode</doc:ref>.</doc:summary></doc:doc>
+ </arg>
+
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ When the system's power supply is critical (critically low batteries or UPS),
+ the system will take this action. Possible values are:
+ <doc:list>
+ <doc:item>
+ <doc:term>HybridSleep</doc:term>
+ </doc:item>
+ <doc:item>
+ <doc:term>Hibernate</doc:term>
+ </doc:item>
+ <doc:item>
+ <doc:term>PowerOff</doc:term>
+ </doc:item>
+ </doc:list>
+ </doc:para>
+ </doc:description>
+ </doc:doc>
+ </method>
<!-- ************************************************************ -->
<signal name="DeviceAdded">
@@ -199,6 +225,23 @@ method return sender=:1.386 -> dest=:1.451 reply_serial=2
</doc:doc>
</property>
+ <property name="LowPowerMode" type="b" access="read">
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ 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.
+ </doc:para>
+ <doc:para>
+ Setting the property is possible for active seats, using the SetLowPowerMode()
+ method.
+ </doc:para>
+ </doc:description>
+ </doc:doc>
+ </property>
+
</interface>
</node>
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
@@ -432,6 +432,19 @@ up_daemon_get_display_device (UpExportedDaemon *skeleton,
}
/**
+ * 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:
**/
static gboolean
@@ -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[] = {