Skip to content

Instantly share code, notes, and snippets.

@hubenchang0515
Created March 16, 2021 01:42
Show Gist options
  • Save hubenchang0515/261ad57ec2fb3d01778336be8a8d5da2 to your computer and use it in GitHub Desktop.
Save hubenchang0515/261ad57ec2fb3d01778336be8a8d5da2 to your computer and use it in GitHub Desktop.
Show X11 idle time - 显示X11空闲时间
// 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