Removing inhibitor wakes up screen

Hi,

I made myself a system (python script) that allows me to set locks/inhibitors to occasionally prevent automatic sleep, and it works very well.
Except that, when I remove the last lock in place, if the display is in sleep mode, it wakes it up and turns my screens back on.

What solution to prevent this wake-up and keep my screens off?

I tried xset -dpms or xset dpms --force off before removing the lock, but it doesn’t change anything. I have the impression that it is linked to the internal management of plasma energy.

Notes:

  • it would be so great if a mechanism allowed inhibitors to also prevent sleep by loginctl suspend/hibernate…
  • the same problem arises with hooks in /etc/elogind/system-sleep. If a hook fails (and this is intentional), it also wakes up the screens. I imagine it is for the same reason.

Gentoo / OpenRC / Plasma6 / X11
elogind-252.9-r2 / powerdevil-6.2.4-r1

Hi - it might help to take a bit of a step back and explain what system state you’re hoping to create with the script you’ve written, so folks can help identify if there are any alternative methods that might avoid whatever you’re running into?

For the approach you’re using now, it might also help to specify the commands you’re currently using - it’s quite possibly my own lack of experience, but it was a bit hard for me to understand exactly what command or sequence was behaving unexpectedly.

Hi,

I don’t think that developing explanations about what I do helps to understand. It will just lead to debates about the appropriateness of my choices, polluting the discussion.
Only someone who knows the mechanisms of inhibitors well can understand, and try to help me, if a solution exists.
Someone who doesn’t know will systematically try to deviate to a subject that he knows, and therefore will not help me.

The problem posed is excessively simple to understand:
Plasma has an inhibition system for sleep mode (among others, but that’s only what interests me here). We place locks that prevent sleep mode. And when we remove the last lock, sleep mode is then possible. We are only talking about automatic sleep mode here. Manual sleep mode (for example by loginctl suspend) is not blocked by these locks.
During the period of inactivity, the display can very well go to sleep, which is logical.

It turns out that here, in the case that concerns me, removing the last lock blocking sleep has 2 actions that bother me:

  • resetting the inactivity duration
  • waking up the display, therefore the screens.

I have proof that it is indeed the removal of the lock (inhibitor) that is the cause, and that it is only when removing the last lock in place (because of course, we can set several locks in parallel).
Here are the events noted by xev when the lock was lifted:

VisibilityNotify event, serial 40, synthetic NO, window 0x5600001,
 state VisibilityFullyObscured

VisibilityNotify event, serial 40, synthetic NO, window 0x5600001,
 state VisibilityUnobscured

Expose event, serial 40, synthetic NO, window 0x5600001,
 (0,0), width 178, height 10, count 3

Expose event, serial 40, synthetic NO, window 0x5600001,
 (0.10), width 10, height 58, count 2

Expose event, serial 40, synthetic NO, window 0x5600001,
 (68,10), width 110, height 58, count 1

Expose event, serial 40, synthetic NO, window 0x5600001,
(0,68), width 178, height 110, count 0

So my question is to know what plasma mechanism causes this operation, and if I could block these events, before removing my last lock, to possibly release them after.
And I think that only a developer of this mechanism will understand what it is.
Thank you for your attention.