From 62b67552e641e3d2e8685e8e8d9e5ed373f3f552 Mon Sep 17 00:00:00 2001 From: Utkarsh Verma Date: Tue, 13 Apr 2021 12:19:34 +0530 Subject: [PATCH] Fix slow loading on first status printing. --- config.h | 2 +- main.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config.h b/config.h index 80ba080..16c61e9 100644 --- a/config.h +++ b/config.h @@ -1,7 +1,7 @@ #define CMDLENGTH 50 #define delimiter "  " -static const Block blocks[] = { +const Block blocks[] = { {"sb-mail", 1800, 1}, {"sb-music", 0, 2}, {"sb-disk", 1800, 4}, diff --git a/main.c b/main.c index a3449f0..3d4b961 100644 --- a/main.c +++ b/main.c @@ -70,8 +70,7 @@ void getCommands(int time) { const Block *current; for (int i = 0; i < len(blocks); i++) { current = blocks + i; - if ((current->interval != 0 && time % current->interval == 0) || - time == -1) + if (time == -1 || (current->interval != 0 && time % current->interval == 0)) getCommand(current, statusbar[i]); } } @@ -177,6 +176,8 @@ void setupSignals() { void statusLoop() { setupSignals(); + getCommands(-1); + writeStatus(); unsigned int sleepInterval = -1; for (int i = 0; i < len(blocks); i++) @@ -186,7 +187,6 @@ void statusLoop() { unsigned int i = 0; struct timespec sleepTime = {sleepInterval, 0}; struct timespec toSleep = sleepTime; - getCommands(-1); while (statusContinue) { // Sleep for `sleepTime` even on being interrupted