From 5400dcfc75b67f9fe677c8712cb60bcd3b947cb2 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Thu, 23 Feb 2023 10:22:56 -0800 Subject: [PATCH] Fix wait time --- dwmblocks.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dwmblocks.c b/dwmblocks.c index ce68340..169a31d 100644 --- a/dwmblocks.c +++ b/dwmblocks.c @@ -4,6 +4,7 @@ #include #include #include +#include #ifndef NO_X #include #endif @@ -167,7 +168,10 @@ void statusloop() { } int i = 0; getcmds(-1); - const struct timespec sleeptime = { 0, interval * 1000000 }; + long nsec_part = interval * 1000000; + time_t sec_part = floor(nsec_part / 1000000000.0); + nsec_part -= sec_part * 1000000000l; + const struct timespec sleeptime = { sec_part, nsec_part }; struct timespec tosleep = sleeptime; while (statuscontinue) { if (nanosleep(&tosleep, &tosleep) < 0) {