Created
March 16, 2021 01:42
-
-
Save hubenchang0515/261ad57ec2fb3d01778336be8a8d5da2 to your computer and use it in GitHub Desktop.
Show X11 idle time - 显示X11空闲时间
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc main.c -lX11 -lXss | |
#include <stdio.h> | |
#include <X11/extensions/scrnsaver.h> | |
int main(void) | |
{ | |
Display* dpy = XOpenDisplay(NULL); | |
if (!dpy) | |
return 1; | |
XScreenSaverInfo* info = XScreenSaverAllocInfo(); | |
while(1) | |
{ | |
XScreenSaverQueryInfo(dpy, DefaultRootWindow(dpy), info); | |
printf("%u\n", info->idle); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment