From ed4ba7e4f652150310d062ffbdfefb4521ce1054 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 21 Feb 2014 21:10:00 +0100 Subject: logind: when we wake up from suspend and the lid is still closed, go to sleep immediately again This is quite useful on laptops such as the Lenovo Yoga, where the power button is placed on the front side of the laptop and can be pressed by accident even if the lid is closed. This reworks a bit of the logind logic to repeatedly try to suspend the system as long as a lid is closed. We use the new "post" event source for this, so that we don't keep things busy. This also adds some code to check the lid status on boot, so that a powered-off machine that is accidentaly powered on goes into suspend immediately. Yay! From now on I can put my Yoga safely in my backpack without fearing that it might turn itself on and drain the battery. --- src/login/logind-action.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/login/logind-action.c') diff --git a/src/login/logind-action.c b/src/login/logind-action.c index 7744addf69..3bad922713 100644 --- a/src/login/logind-action.c +++ b/src/login/logind-action.c @@ -80,6 +80,10 @@ int manager_handle_action( /* Locking is handled differently from the rest. */ if (handle == HANDLE_LOCK) { + + if (!is_edge) + return 0; + log_info("Locking sessions..."); session_send_lock_all(m, true); return 1; -- cgit v1.2.3-54-g00ecf