Windows has the SetThreadExecutionState method that enables you to prevent monitor standby during program execution.

I'm searching for a Linux equivalent, but I can't find anything useful.

I don't want to disable the screensaver by calling a command, because if the program crashes after that, the screensaver will stay disabled until the user re-enables it.

The program is written in Qt, so a Qt friendly solution would be great.

Ideas anyone?

有帮助吗?

解决方案

I was looking for this and couldn't find a solution, but instead a workaround. Launching at the same time as the application (a video player) a little script to periodically check if the application process is alive, and if it isn't, re-enable the screensaver. In my case using xset s on and xset s off, then end the checker process itself. You can probably fork a process to the background so it stays alive and does its re-enable job reliably.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top