From 41deab98a5c0ac7162cd2fe21a786e022cc53670 Mon Sep 17 00:00:00 2001 From: clsr Date: Fri, 2 Jul 2021 03:48:06 +0000 Subject: Add dwmclock-print --- dwmclock.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'dwmclock.c') diff --git a/dwmclock.c b/dwmclock.c index 95a0db0..4bc043c 100644 --- a/dwmclock.c +++ b/dwmclock.c @@ -7,7 +7,9 @@ #include #include #include +#ifndef PRINT #include +#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; } -- cgit