gpt4 book ai didi

linux - 如何检查 Linux 控制台屏幕保护程序是否有黑屏

转载 作者:IT王子 更新时间:2023-10-29 00:10:22 28 4
gpt4 key购买 nike

有没有办法以编程方式(通过 ioctl() 等)或通过读取/sys、/proc 或/dev 中的文件来检查屏幕是否已被 Linux 控制台屏幕保护程序黑屏?

谢谢和最好的问候,

君特

最佳答案

好的,检查了xset source code .相关代码部分为

#include <X11/extensions/dpms.h>
...
Display* dpy = XOpenDisplay(NULL);
...
int dummy;
CARD16 standby, suspend, off;
BOOL onoff;
CARD16 state;

printf("DPMS (Energy Star):\n");
if (DPMSQueryExtension(dpy, &dummy, &dummy))
{
if (DPMSCapable(dpy))
{
DPMSGetTimeouts(dpy, &standby, &suspend, &off);
printf (" Standby: %d Suspend: %d Off: %d\n",
standby, suspend, off);
DPMSInfo(dpy, &state, &onoff);
if (onoff)
{
printf(" DPMS is Enabled\n");
switch (state)
{
case DPMSModeOn:
printf(" Monitor is On\n");
break;
case DPMSModeStandby:
printf(" Monitor is in Standby\n");
break;
case DPMSModeSuspend:
printf(" Monitor is in Suspend\n");
break;
case DPMSModeOff:
printf(" Monitor is Off\n");
break;
default:
printf(" Unrecognized response from server\n");
}
}
}
}

以防万一其他人需要这个;-)

关于linux - 如何检查 Linux 控制台屏幕保护程序是否有黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3819255/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com