Points extracted from MR !344 which I'm going to push, to make sure that the issue lives on once the MR is merged.
PowerDevil::Core
handles PowerDevil::PolicyAgent::sessionActiveChanged
and clears action timers there. However, on other events such as plugging AC in or out, loadProfile()
/loadAction()
gets called anyway and idle timers get reinstated. In a multi-user-setup, this means the following can happen:
- I switch from Plasma session A (owned by user X) to Plasma session B (owned by user Y).
- Each session runs its own powerdevil.
- I plug in the laptop.
- AC profile gets loaded for both powerdevils, actions get reloaded even for the inactive powerdevil, idle timers are restarted also for both.
- The auto-suspend idle timer expires for the inactive session's PowerDevil, so its "SuspendSession" action tries to suspend the system.
- Luckily systemd is against it because the session is inactive.
- When switching back to the session, now there's an auth dialog from earlier, asking to authorize the suspend action.
- Luckily systemd is against it because the session is inactive.
In order to prevent unintentional surprises, we may want to avoid loadProfile()
calls or at least loadAction()
within it as long as the session is inactive.