mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-04-04 22:30:39 +02:00
Add a LidForceSleep property to ensure that we don't melt any laptops
We still need to add the DMI quirks, but I'm waiting for the community to supply them now.
This commit is contained in:
parent
6343de2dd6
commit
b31de44eee
5 changed files with 95 additions and 0 deletions
|
|
@ -64,6 +64,7 @@ struct _UpClientPrivate
|
|||
gboolean on_battery;
|
||||
gboolean on_low_battery;
|
||||
gboolean lid_is_present;
|
||||
gboolean lid_force_sleep;
|
||||
gboolean is_docked;
|
||||
gboolean done_enumerate;
|
||||
};
|
||||
|
|
@ -85,6 +86,7 @@ enum {
|
|||
PROP_ON_LOW_BATTERY,
|
||||
PROP_LID_IS_CLOSED,
|
||||
PROP_LID_IS_PRESENT,
|
||||
PROP_LID_FORCE_SLEEP,
|
||||
PROP_IS_DOCKED,
|
||||
PROP_LAST
|
||||
};
|
||||
|
|
@ -419,6 +421,17 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
|
|||
g_object_notify (G_OBJECT(client), "is-docked");
|
||||
}
|
||||
|
||||
value = g_hash_table_lookup (props, "LidForceSleep");
|
||||
if (value == NULL) {
|
||||
g_warning ("No 'LidForceSleep' property");
|
||||
goto out;
|
||||
}
|
||||
ret = g_value_get_boolean (value);
|
||||
if (ret != client->priv->lid_force_sleep) {
|
||||
client->priv->lid_force_sleep = ret;
|
||||
g_object_notify (G_OBJECT(client), "lid-force-sleep");
|
||||
}
|
||||
|
||||
/* cached */
|
||||
client->priv->have_properties = TRUE;
|
||||
|
||||
|
|
@ -500,6 +513,24 @@ up_client_get_lid_is_present (UpClient *client)
|
|||
return client->priv->lid_is_present;
|
||||
}
|
||||
|
||||
/**
|
||||
* up_client_get_lid_force_sleep:
|
||||
* @client: a #UpClient instance.
|
||||
*
|
||||
* Get whether the laptop has to sleep when the lid is closed.
|
||||
*
|
||||
* Return value: %TRUE if the session has to suspend
|
||||
*
|
||||
* Since: 0.9.9
|
||||
*/
|
||||
gboolean
|
||||
up_client_get_lid_force_sleep (UpClient *client)
|
||||
{
|
||||
g_return_val_if_fail (UP_IS_CLIENT (client), FALSE);
|
||||
up_client_get_properties_sync (client, NULL, NULL);
|
||||
return client->priv->lid_force_sleep;
|
||||
}
|
||||
|
||||
/**
|
||||
* up_client_get_is_docked:
|
||||
* @client: a #UpClient instance.
|
||||
|
|
@ -681,6 +712,9 @@ up_client_get_property (GObject *object,
|
|||
case PROP_LID_IS_PRESENT:
|
||||
g_value_set_boolean (value, client->priv->lid_is_present);
|
||||
break;
|
||||
case PROP_LID_FORCE_SLEEP:
|
||||
g_value_set_boolean (value, client->priv->lid_force_sleep);
|
||||
break;
|
||||
case PROP_IS_DOCKED:
|
||||
g_value_set_boolean (value, client->priv->is_docked);
|
||||
break;
|
||||
|
|
@ -801,6 +835,21 @@ up_client_class_init (UpClientClass *klass)
|
|||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/**
|
||||
* UpClient:lid-force-sleep:
|
||||
*
|
||||
* If a laptop has to sleep if the lid is closed.
|
||||
*
|
||||
* Since: 0.9.9
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_LID_FORCE_SLEEP,
|
||||
g_param_spec_boolean ("lid-force-sleep",
|
||||
"If a laptop has to sleep on lid close",
|
||||
NULL,
|
||||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/**
|
||||
* UpClient:is-docked:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ const gchar *up_client_get_daemon_version (UpClient *client);
|
|||
gboolean up_client_get_can_hibernate (UpClient *client);
|
||||
gboolean up_client_get_lid_is_closed (UpClient *client);
|
||||
gboolean up_client_get_lid_is_present (UpClient *client);
|
||||
gboolean up_client_get_lid_force_sleep (UpClient *client);
|
||||
gboolean up_client_get_is_docked (UpClient *client);
|
||||
gboolean up_client_get_can_suspend (UpClient *client);
|
||||
gboolean up_client_get_on_battery (UpClient *client);
|
||||
|
|
|
|||
|
|
@ -304,6 +304,24 @@ method return sender=:1.386 -> dest=:1.451 reply_serial=2
|
|||
</doc:doc>
|
||||
</property>
|
||||
|
||||
<property name="LidForceSleep" type="b" access="read">
|
||||
<doc:doc>
|
||||
<doc:description>
|
||||
<doc:para>
|
||||
If the system really has to sleep when the lid is closed.
|
||||
Some laptops actually melt (!) if the lid is closed and the
|
||||
computer keeps running. We blacklist those, and do something
|
||||
sane for the other machines.
|
||||
</doc:para>
|
||||
<doc:para>
|
||||
This allows us to set the default session policy to not
|
||||
suspend on lid close if the laptop is docked, and be sure
|
||||
the machine is not going to melt.
|
||||
</doc:para>
|
||||
</doc:description>
|
||||
</doc:doc>
|
||||
</property>
|
||||
|
||||
<property name="IsDocked" type="b" access="read">
|
||||
<doc:doc>
|
||||
<doc:description>
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ enum
|
|||
PROP_ON_LOW_BATTERY,
|
||||
PROP_LID_IS_CLOSED,
|
||||
PROP_LID_IS_PRESENT,
|
||||
PROP_LID_FORCE_SLEEP,
|
||||
PROP_IS_DOCKED,
|
||||
PROP_LAST
|
||||
};
|
||||
|
|
@ -79,6 +80,7 @@ struct UpDaemonPrivate
|
|||
gboolean on_low_battery;
|
||||
gboolean lid_is_closed;
|
||||
gboolean lid_is_present;
|
||||
gboolean lid_force_sleep;
|
||||
gboolean is_docked;
|
||||
gboolean kernel_can_suspend;
|
||||
gboolean kernel_can_hibernate;
|
||||
|
|
@ -762,6 +764,18 @@ up_daemon_set_lid_is_closed (UpDaemon *daemon, gboolean lid_is_closed)
|
|||
g_object_notify (G_OBJECT (daemon), "lid-is-closed");
|
||||
}
|
||||
|
||||
/**
|
||||
* up_daemon_set_lid_force_sleep:
|
||||
**/
|
||||
void
|
||||
up_daemon_set_lid_force_sleep (UpDaemon *daemon, gboolean lid_force_sleep)
|
||||
{
|
||||
UpDaemonPrivate *priv = daemon->priv;
|
||||
g_debug ("lid_force_sleep = %s", lid_force_sleep ? "yes" : "no");
|
||||
priv->lid_force_sleep = lid_force_sleep;
|
||||
g_object_notify (G_OBJECT (daemon), "lid-enforce-sleep");
|
||||
}
|
||||
|
||||
/**
|
||||
* up_daemon_set_lid_is_present:
|
||||
**/
|
||||
|
|
@ -1150,6 +1164,9 @@ up_daemon_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe
|
|||
case PROP_LID_IS_PRESENT:
|
||||
g_value_set_boolean (value, priv->lid_is_present);
|
||||
break;
|
||||
case PROP_LID_FORCE_SLEEP:
|
||||
g_value_set_boolean (value, priv->lid_force_sleep);
|
||||
break;
|
||||
case PROP_IS_DOCKED:
|
||||
g_value_set_boolean (value, priv->is_docked);
|
||||
break;
|
||||
|
|
@ -1249,6 +1266,14 @@ up_daemon_class_init (UpDaemonClass *klass)
|
|||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_LID_FORCE_SLEEP,
|
||||
g_param_spec_boolean ("lid-enforce-sleep",
|
||||
"Enforce sleep on lid close",
|
||||
"If this computer has to sleep on lid close",
|
||||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_IS_DOCKED,
|
||||
g_param_spec_boolean ("is-docked",
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@ void up_daemon_set_lid_is_closed (UpDaemon *daemon,
|
|||
gboolean lid_is_closed);
|
||||
void up_daemon_set_lid_is_present (UpDaemon *daemon,
|
||||
gboolean lid_is_present);
|
||||
void up_daemon_set_lid_force_sleep (UpDaemon *daemon,
|
||||
gboolean lid_force_sleep);
|
||||
void up_daemon_set_is_docked (UpDaemon *daemon,
|
||||
gboolean is_docked);
|
||||
void up_daemon_set_on_battery (UpDaemon *daemon,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue