policyagent, applet: support blocking inhibitions
Allow the user to release, and optionally configure to permanently reject, inhibitions from certain apps for certain reasons, with new buttons in the applet's inhibition hint.
Expose the following new methods and signals via D-Bus:
-
BlockInhibition
: Release any current inhibitions that match the pattern. If set to permanent, also reject any new inhibitions from that app with that reason. Permanently blocked inhibitions are kept track of in a list saved in the powerdevil configuration file. -
UnblockInhibition
: Retroactively inforce matching inhibitions that were previously released or rejected but are still relevant. If set to permanent, remove the pair from the list in the config if applicable. -
ListPermanentlyBlockedInhibitions
,ListTemporarilyBlockedInhibitions
: List all inhibitions that that would currently be active but were released or rejected on user request. -
PermanentlyBlockedInhibitionsChanged
,TemporarilyBlockedInhibitionsChanged
: Emitted when blocked inhibitions are added or removed.
In the applet, add buttons in the inhibition hint using this new DBus interface.
Also in the applet, adopt the same layout in the manual inhibition control. This makes the UI less visually busy and puts more focus on the probably more interesting app inhibitions.
Before: | After: |
---|---|
For motivation of why such functionality is desired, see the bug report.
How to test:
- Build the branch
- Restart powerdevil:
systemctl --user restart plasma-powerdevil.service
and the Plasma applet - Play a video and wait five seconds for the inhibition to appear
- Press the button
- Confirm computer automatically goes to sleep after the inactivity period set in power management settings even while video is still playing
- Confirm that the "every time" option will also take effect when you repeat the same steps again, and the "only this time" option will not
- Confirm the applet shows you a message informing about this, and that the "Block" button undoes it as expected
CC @broulik
Edited by Natalie Clarius