diff options
Diffstat (limited to 'dwmclock.c')
-rw-r--r-- | dwmclock.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -7,7 +7,9 @@ #include <string.h> #include <time.h> #include <unistd.h> +#ifndef PRINT #include <X11/Xlib.h> +#endif /* PRINT */ int stop = 0; @@ -78,10 +80,12 @@ int main(void) char *clock = name; #endif /* BATTERY */ struct sigaction act; +#ifndef PRINT Display *disp; int screen; Window root; char *origname = NULL; +#endif /* !PRINT */ act.sa_handler = handler; act.sa_flags = 0; @@ -91,6 +95,7 @@ int main(void) sigaction(SIGQUIT, &act, NULL); sigaction(SIGTERM, &act, NULL); +#ifndef PRINT if (!(disp = XOpenDisplay(NULL))) { return EXIT_FAILURE; } @@ -100,9 +105,10 @@ int main(void) } XFetchName(disp, root, &origname); - fclose(stdin); fclose(stdout); fclose(stderr); +#endif /* !PRINT */ + fclose(stdin); #ifdef BATTERY for (i=0; !stop; ++i) { @@ -146,8 +152,13 @@ int main(void) tm = localtime(&now); strftime(clock, 9, "%H:%M:%S", tm); +#ifdef PRINT + printf("%s\n", name); + fflush(stdout); +#else XStoreName(disp, root, name); XFlush(disp); +#endif /* PRINT */ #ifdef EXACT_SLEEP ts.tv_sec = 0; @@ -158,10 +169,12 @@ int main(void) #endif /* EXACT_SLEEP */ } +#ifndef PRINT if (origname) { XStoreName(disp, root, origname); } XCloseDisplay(disp); +#endif /* !PRINT */ return EXIT_SUCCESS; } |