Fix slow loading on first status printing.

This commit is contained in:
Utkarsh Verma 2021-04-13 12:19:34 +05:30
parent 5465c43cff
commit 62b67552e6
No known key found for this signature in database
GPG Key ID: 611291C16E1D6F95
2 changed files with 4 additions and 4 deletions

View File

@ -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},

6
main.c
View File

@ -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