From c265691e73e19a807399d5847904efeafc7891dd Mon Sep 17 00:00:00 2001 From: Ashish Kumar Yadav Date: Sun, 4 Apr 2021 13:33:06 +0530 Subject: [PATCH] Improved interval handling --- config.def.h | 5 ++--- dwmblocks.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/config.def.h b/config.def.h index 0eb2264..8e53261 100644 --- a/config.def.h +++ b/config.def.h @@ -37,9 +37,8 @@ static const char delimiter[] = { ' ', ' ', ' ', DELIMITERENDCHAR }; one newline character at the end) * pathc - path of the program used for handling clicks on the block */ -/* 1 interval = INTERVALs seconds, INTERVALn nanoseconds */ -#define INTERVALs 1 -#define INTERVALn 0 +/* 1 interval = seconds, nanoseconds */ +static const struct timespec interval = { 1, 0 }; static Block blocks[] = { /* pathu pathc interval signal */ diff --git a/dwmblocks.c b/dwmblocks.c index cc9feb6..98089c5 100644 --- a/dwmblocks.c +++ b/dwmblocks.c @@ -139,7 +139,7 @@ statusloop() updateblock(block, NILL); updatestatus(); sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL); - t.tv_sec = INTERVALs, t.tv_nsec = INTERVALn; + t = interval; while (nanosleep(&t, &t) == -1) if (errno != EINTR) { perror("statusloop - nanosleep"); @@ -153,7 +153,7 @@ statusloop() updateblock(block, NILL); updatestatus(); sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL); - t.tv_sec = INTERVALs, t.tv_nsec = INTERVALn; + t = interval; while (nanosleep(&t, &t) == -1); } }