0

I develop [cross-platform C++ Qt-based] application which plays video using libVLC. When i watch video for a long time, my monitor is going to turn off according with power management settings. I want to disable auto turning off while video is playing as it is in Totem, VLC media player and other Ubuntu media players. But i can't find how to do this from C++ code using Ubuntu libraries.

For example, under Windows i can do that using:

SetThreadExecutionState( ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED | ES_CONTINUOUS );

Everything i found about Linux/Ubuntu is how to patch some config files. I can't do this from code:

  1. User that run app obiously may have no rights to edit configs
  2. Power settings must be restored anyway when video stops but if my app suddenly crashed it will not happen
  3. Different Ubuntu versions may have different config files and entries

So my questions:

  • is there a some Ubuntu (or Qt and libVLC) library functions which suppress monitor turning off and system sleep?
  • how popular Ubuntu video players implements such behaviour?
0

I would recommend you to have a look at the code of xset, a tool that's part of X.org, or any other program that can already do these things you want to do (you can disable the screen turning off with xset -dpms + xset s off).

In the case of xset, you'll find the source code here, or for when that link will be outdated:

http://www.x.org/releases/current/
-> Source Tar Files for X11RX.Y
-> app/
-> xset-x.y.z.tar.{bz2,gz}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.