aboutsummaryrefslogtreecommitdiffstats
path: root/dwmclock.c
diff options
context:
space:
mode:
authorclsr <clsr@clsr.net>2021-07-02 03:48:06 +0000
committerclsr <clsr@clsr.net>2021-07-02 03:48:06 +0000
commit41deab98a5c0ac7162cd2fe21a786e022cc53670 (patch)
treec495121579c79c61e06d25ba4a2ed1b9b7fa82f0 /dwmclock.c
parent50e382e5efe6bdad568a507e7ec675e27e94d428 (diff)
downloaddwmclock-41deab98a5c0ac7162cd2fe21a786e022cc53670.tar.gz
dwmclock-41deab98a5c0ac7162cd2fe21a786e022cc53670.zip
Add dwmclock-printv1.4.0
Diffstat (limited to 'dwmclock.c')
-rw-r--r--dwmclock.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/dwmclock.c b/dwmclock.c
index 95a0db0..4bc043c 100644
--- a/dwmclock.c
+++ b/dwmclock.c
@@ -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;
}