Align with full minute

This commit is contained in:
Przemek Grondek 2022-07-26 00:06:32 +02:00
parent 7d098f0869
commit 1b017e36d0

View File

@ -206,9 +206,7 @@ gettemperature(char *base, char *sensor)
return smprintf("%02.0f°C", atof(co) / 1000); return smprintf("%02.0f°C", atof(co) / 1000);
} }
int void update() {
main(void)
{
char *status; char *status;
char *avgs; char *avgs;
char *tmbln; char *tmbln;
@ -216,12 +214,6 @@ main(void)
char *bat; char *bat;
char *brightness; char *brightness;
if (!(dpy = XOpenDisplay(NULL))) {
fprintf(stderr, "dwmstatus: cannot open display.\n");
return 1;
}
for (;;sleep(60)) {
avgs = loadavg(); avgs = loadavg();
tmbln = mktimes("%H:%M %d.%m.%Y", tzwarsaw); tmbln = mktimes("%H:%M %d.%m.%Y", tzwarsaw);
t0 = gettemperature("/sys/class//hwmon/hwmon1", "temp1_input"); t0 = gettemperature("/sys/class//hwmon/hwmon1", "temp1_input");
@ -238,6 +230,30 @@ main(void)
free(tmbln); free(tmbln);
free(status); free(status);
free(brightness); free(brightness);
}
void sleepUntilFullMinute() {
time_t tim;
struct tm *tm;
tim = time(NULL);
tm = localtime(&tim);
int seconds_left = 60 - tm->tm_sec;
sleep(seconds_left);
}
int
main(void)
{
if (!(dpy = XOpenDisplay(NULL))) {
fprintf(stderr, "dwmstatus: cannot open display.\n");
return 1;
}
update();
sleepUntilFullMinute();
for (;;sleep(60)) {
update();
} }
XCloseDisplay(dpy); XCloseDisplay(dpy);