autosuspend icon indicating copy to clipboard operation
autosuspend copied to clipboard

Autosuspend should respect systemd inhibit locks

Open Flowdalic opened this issue 1 year ago • 4 comments

Autosuspend currently only evaluates the idle hint of logind sessions. However, it should also consider inhibit locks.

From man logind.conf(5)'s IdleAction description:

Note that this requires that user sessions correctly report the idle status to the system. The system will execute the action after all sessions report that they are idle, no idle inhibitor lock is active, and subsequently, the time configured with IdleActionSec= (see below) has expired.

Ideally autosuspend would not perform idle checks if an idle inhibit lock is taken and consider the system active. And not invoke suspend if a sleep inhibit lock is taken.

Flowdalic avatar Aug 16 '23 14:08 Flowdalic

This could be added a another activity check.

languitar avatar Aug 18 '23 10:08 languitar

This could be added a another activity check.

It could, but it would be slightly changing the semantic of the (idle) inhibit lock. The system's idle period would then start once the inhibit lock is released. When it should start once the last session became idle.

Flowdalic avatar Aug 21 '23 08:08 Flowdalic

Is that a serious problem for your use case? Due to the periodic nature of autosuspend there's always a chance that (in)activity is missed or detected only delayed. I never had the ambition to build a tool that suspends the system accurately to the second. For saving energy, suspending one or two minutes later every now and then shouldn't be a real problem?

languitar avatar Aug 21 '23 20:08 languitar

I was just pointing out that there is a semantic difference between a non-idle session and a idle inhibit lock.

For saving energy, suspending one or two minutes later every now and then shouldn't be a real problem?

I think it's more then just a minute or two. Once the idle inhibit lock is gone, the system could be already idle long enough right away. Instead you have to wait the whole idle_time again.

Flowdalic avatar Aug 22 '23 08:08 Flowdalic