Automatically switch DPMS off in VLC 2.1

For a little while now I've been using a little module of my own to handle switching DPMS off automatically when playing, but as I recently upgraded to VLC 2.1 it broke.

I had to have a look at this again, and after fixing it I figured I might as well share this, since I hadn't really done so yet, in case it might turn useful to someone else, maybe you.

Why is anything needed at all? VLC does it on its own...

It is absolutely true that VLC comes with an option to "inhibit power management daemon during playback" and a few modules to take care of that. There are, however, a couple reasons why that didn't work for me.

First of all is the fact that I'm not using a session manager, which means I might have a few things that would otherwise work fine, not actually work for me. This is my choice and I'm fine with it, I still don't see the need for me to have a session manager.

However, it is possible that the module "Inhibits power suspend and session idle timeout" would work if I had one, or that xdg-screensaver (which is used by the module "XDG screen saver inhibition") might work (better) as well (little more on that in a bit).

Thing is, though, that it would still not meet my needs; And that's because of how the whole inhibition system works in VLC, which - if I'm not mistaken - is meant to start inhibition when playing a media, and until it stops.

Sounds about right, but the key word here is stop, it means that quite literally, as in you need to hit "Stop" for it to be triggered, "Pause" won't do it.

Now this might be what most people want, but not me. I happen to sometimes have say a video running, I hit pause and go AFK for a few minutes, or hours. And when that happens, I want my screens to go off, even though I did not hit "Stop" (as I intend to come back and resume playing just where I was, thank you very much).

For that reason, the "inhibit" capability of VLC's modules isn't really working for me, and that would be the case even if I had a session manager running.

How to handle the switching off & on

I'm not exactly sure how the DBus module works, since I didn't really look into it, but as explained above, the whole "inhibit" system in VLC makes it work on Play & Stop only, not Pause.

The way the XDG module works, is that it will call xdg-screensaver reset every 30s or so from the moment you play a video, and until you stop it. As hinted, this doesn't really do anything for me, but I believe the intent is to prevent the screensaver to kick in while playing the media.

As I said, not at all what I was looking for. But besides adding the event for "Pause" I decided to approach things a bit differently (if only, because that method wouldn't work for me, of course).

I decided to trigger an action on "Play", and another one on "Pause" or "Stop." This could (should?) have been xdg-screensaver suspend/resume <window-id> but, as you guessed, isn't what I went with.

The reason isn't due to my lack of session manager this time, but that I also do not have xprop installed either, which is required by xdg-screensaver to handle the whole "tracking of the window" bit that happens behind those suspend/resume commands.

Not having it installed, those calls are simply turning DPMS off and on. So I might as well just do that (e.g. call xset +dpms directly), and that's what I did.

It's proper, but another reason to do that, was that I have no idea how to get the window ID for VLC's window, and was too lazy to go find out.

A new module, switching DPMS off on play, and back on on pause/stop

And that's how this module was born. It registers its capability under "interface" and not "inhibit" because, as explained, the latter didn't allow to handle the switch on pause, as I wanted.

Once the module written & compiled, all I had to do was turn off the option for inhibiting the screen saver (since it's useless for me, no need to have some module uselessly calling xdg-screensaver every so often) and also add "dpms" (the name of the module) under "Extra interfaces modules."

This is option "extraintf" in vlcrc (or on command-line), and for some reason while it is in my vlcrc file, it doesn't show up when I open the Preferences window in VLC. I'm not sure why, I don't doubt that next time I save my preferences it will remove it, which will lead to me getting annoyed when my monitor will go black in the middle of a video, so if anyone knows why/how to fix it, please let me know -- thanks.

Anyhow, that was it. Now it works as I like/expect, I'm happy again. If you're interested you can find the patch to add this module on Github.

Off topic: window won't get small no more

Just as an extra note: In my constant aim to save pixels, I had tweaked VLC's interface, notably to put the time slider in the main toolbar in order to get rid of the time toolbar.

This worked well in previous versions, but since 2.1 it's broken, and the window would refuse to have its width under 800 pixels or so. Incredibly annoying, so I had to use the useless time toolbar again and waste so many space (but at least I can resize the window however I want again).

In case that happened to you as well, and you're wondering why/how to "fix" it.

Top of Page