summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2011-03-28 16:41:02 +0100
committerRichard Hughes <richard@hughsie.com>2011-03-28 16:41:02 +0100
commitc98ca6f8f5d893b747779ba037b75b1d25d4821c (patch)
tree4062f6ecb02bfa0f30a446027f2de7f4062055d7
parent37875310965541c8774b495397814d4b3780f0b6 (diff)
Add a config option 'IgnoreLid' so users with broken / inverted lid switches don't suspend at session start
-rw-r--r--etc/UPower.conf9
-rw-r--r--src/up-daemon.c18
2 files changed, 27 insertions, 0 deletions
diff --git a/etc/UPower.conf b/etc/UPower.conf
index ca120dc..c9da9cd 100644
--- a/etc/UPower.conf
+++ b/etc/UPower.conf
@@ -43,3 +43,12 @@ EnableWattsUpPro=true
# default=false
PollDockDevices=false
+# Do we ignore the lid state
+#
+# Some laptops are broken. The lid state is either inverted, or stuck
+# on or off. We can't do much to fix these problems, but this is a way
+# for users to make the laptop panel vanish and for programs like
+# gnome-power-manager to not suspend on system startup.
+#
+# default=false
+IgnoreLid=false
diff --git a/src/up-daemon.c b/src/up-daemon.c
index 4276243..12bd999 100644
--- a/src/up-daemon.c
+++ b/src/up-daemon.c
@@ -32,6 +32,7 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
+#include "up-config.h"
#include "up-polkit.h"
#include "up-device-list.h"
#include "up-device.h"
@@ -73,6 +74,7 @@ struct UpDaemonPrivate
{
DBusGConnection *connection;
DBusGProxy *proxy;
+ UpConfig *config;
UpPolkit *polkit;
UpBackend *backend;
UpDeviceList *power_devices;
@@ -759,6 +761,13 @@ void
up_daemon_set_lid_is_closed (UpDaemon *daemon, gboolean lid_is_closed)
{
UpDaemonPrivate *priv = daemon->priv;
+
+ /* check if we are ignoring the lid */
+ if (up_config_get_boolean (priv->config, "IgnoreLid")) {
+ g_debug ("ignoring lid state");
+ return;
+ }
+
g_debug ("lid_is_closed = %s", lid_is_closed ? "yes" : "no");
priv->lid_is_closed = lid_is_closed;
g_object_notify (G_OBJECT (daemon), "lid-is-closed");
@@ -783,6 +792,13 @@ void
up_daemon_set_lid_is_present (UpDaemon *daemon, gboolean lid_is_present)
{
UpDaemonPrivate *priv = daemon->priv;
+
+ /* check if we are ignoring the lid */
+ if (up_config_get_boolean (priv->config, "IgnoreLid")) {
+ g_debug ("ignoring lid state");
+ return;
+ }
+
g_debug ("lid_is_present = %s", lid_is_present ? "yes" : "no");
priv->lid_is_present = lid_is_present;
g_object_notify (G_OBJECT (daemon), "lid-is-present");
@@ -1028,6 +1044,7 @@ up_daemon_init (UpDaemon *daemon)
daemon->priv = UP_DAEMON_GET_PRIVATE (daemon);
daemon->priv->polkit = up_polkit_new ();
+ daemon->priv->config = up_config_new ();
daemon->priv->lid_is_present = FALSE;
daemon->priv->is_docked = FALSE;
daemon->priv->lid_is_closed = FALSE;
@@ -1345,6 +1362,7 @@ up_daemon_finalize (GObject *object)
dbus_g_connection_unref (priv->connection);
g_object_unref (priv->power_devices);
g_object_unref (priv->polkit);
+ g_object_unref (priv->config);
g_object_unref (priv->backend);
g_timer_destroy (priv->about_to_sleep_timer);