Advertisement
Guest User

nix-shell output

a guest
Jul 1st, 2017
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. [swflint@curry] git:(master 2↑) 1M~/bin% nix-shell -p xlibs.libXScrnSaver
  2.  
  3. [nix-shell:~/bin]$ cat x11idle.c
  4. #include <X11/extensions/scrnsaver.h>
  5. #include <stdio.h>
  6.  
  7. /* Based on code from
  8. * http://coderrr.wordpress.com/2008/04/20/getting-idle-time-in-unix/
  9. *
  10. * compile with 'gcc -l Xss x11idle.c -o x11idle' and copy x11idle into your
  11. * path
  12. */
  13.  
  14. int main() {
  15. XScreenSaverInfo *info = XScreenSaverAllocInfo();
  16. //open the display specified by the DISPLAY environment variable
  17. Display *display = XOpenDisplay(0);
  18.  
  19. //display could be null if there is no X server running
  20. if (info == NULL || display == NULL) {
  21. return -1;
  22. }
  23.  
  24. //X11 is running, try to retrieve info
  25. if (XScreenSaverQueryInfo(display, DefaultRootWindow(display), info) == 0) {
  26. return -1;
  27. }
  28.  
  29. //info was retrieved successfully, print idle time
  30. printf("%lu\n", info->idle);
  31. return 0;
  32. }
  33.  
  34. [nix-shell:~/bin]$ gcc -l xSS x11idle.c -o x11idle
  35. x11idle.c:1:38: fatal error: X11/extensions/scrnsaver.h: No such file or directory
  36. compilation terminated.
  37.  
  38. [nix-shell:~/bin]$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement