How to programmatically disable focus stealing prevention?

I wanted MPV to start playing in fullscreen when the computer is left idling. I wrote a Python script that calls MPV with parameters that cause it to go fullscreen, loop the video and quit on any input. But I have run into an unexpected problem.

If I run mpv directly, or run my script, from Yakuake or from Alt+F2, it all works fine, and MPV takes the whole screen.

However, if I set my script to run on idle in Power settings, then when MPV opens, plasma panels are drawn on top of it.

I know that the culprit is Focus Stealing Prevention, and I can solve the problem for myself by creating a Window Rule to disable it for my instance of MPV. However, I want to distribute my script and I value simplicity — and I really don’t want to tell my users that they need to create a window rule to use my script. For the same reason i don’t want to alter mpv in any way for it.

So how can I either:

  • Disable Focus Stealing Prevention for an application before running it
  • Create a Window Rule programmatically without user input
  • Force MPV to get on top of panels in any other way?

Thanks!

That could also be a bug.

Maybe the part of Plasma that launches the “idle action” needs to set the window activation token so that whatever program is started can become the active window.

I also noticed that in the same situation the mouse pointer sometimes shows on top of the video, despite all options to hide it enabled. If I move the mouse, the pointer disappears. I can’t cause the pointer to move to the edge of the screen on Wayland, right?