How to heartbeat X11 screensaver?

寵の児 提交于 2019-12-02 05:55:09

问题


X11 has a screensaver mechanism that can be controlled by xset command. Without having to invoke the external command to disable or heartbeat the screensaver, from inside my X11 application, how can I heartbeat the screensaver mechanism so to prevent it from shutting down the monitor?


回答1:


If this on a modern Linux system, the preferred FreeDesktop method is to ping the DBus interface, specifically org.freedesktop.ScreenSaver.SimulateUserActivity() or another part of the exposed interface, depending on your needs.




回答2:


As well as the D-Bus solution suggested by @Kitsune. You can also take the approach that some media players do and simulate the pressing of a key (e.g. Alt) at regular intervals.

This code in totem: http://git.gnome.org/browse/totem/tree/lib/totem-scrsaver.c is designed to be dropped into your code base (it's LGPL v2.1) and will use both the D-Bus interface and also use XTest to synthesize pressing the Alt key every 30s.



来源:https://stackoverflow.com/questions/9369502/how-to-heartbeat-x11-screensaver

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!