Comment 9 for bug 1668596

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> Question, does repowerd "know" there's a lid involved? (or could we make it know there's a lid involved)

It knows about the lid, so we could customize the behavior just for the lid-closing action.

> I'm open to other thoughts - but I can't imagine where a user would expect their device to not suspend with a lid being shut.

> For example when you're downloading some files in the background, or watching a video on an external screen - your laptop might be docked and closed in that case.

repowerd already handles the external display case and doesn't suspend if an external display is connected and active when the lid is closed (you can still suspend explicitly or by inactivity timeout if configured).

In other cases, whether closing the lid should respect suspend blocks is a matter of trade-offs:

+ The user won't inadvertently interrupt a critical operation that has acquired a suspend block (e.g. flashing a firmware update)
+ A suspend block is more meaningful, provides stronger guarantees
+ Better support for multiple user sessions (e.g. a non-active user is flashing firmware and the active user closes the lid)
- Broken (malicious?) apps holding suspend blocks for more than required can keep the device awake
- Closing the lid has unpredictable behavior (may or may not suspend)

An approach I have been considering for the past few days and I am warming up to:

* Closing the lid (if configured to suspend) and explicitly suspending, should not take into account blocks and should suspend unconditionally UNLESS any blocks have been requested by a privileged (euid=0) process.

* Suspending after an inactivity timeout (if configured) should always take into account suspend blocks

The differentiation is that the first case involves explicit user actions, whereas the second case does not. The "UNLESS" part in the first case allows privileged processes to force suspend blocks for very important cases (e.g. firmware updates).

For the cases the user doesn't want to suspend after closing the lid they can change the setting in the power settings dialog.

Thoughts?