Align with full minute
This commit is contained in:
parent
7d098f0869
commit
1b017e36d0
34
dwmstatus.c
34
dwmstatus.c
@ -206,9 +206,7 @@ gettemperature(char *base, char *sensor)
|
||||
return smprintf("%02.0f°C", atof(co) / 1000);
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
void update() {
|
||||
char *status;
|
||||
char *avgs;
|
||||
char *tmbln;
|
||||
@ -216,12 +214,6 @@ main(void)
|
||||
char *bat;
|
||||
char *brightness;
|
||||
|
||||
if (!(dpy = XOpenDisplay(NULL))) {
|
||||
fprintf(stderr, "dwmstatus: cannot open display.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (;;sleep(60)) {
|
||||
avgs = loadavg();
|
||||
tmbln = mktimes("%H:%M %d.%m.%Y", tzwarsaw);
|
||||
t0 = gettemperature("/sys/class//hwmon/hwmon1", "temp1_input");
|
||||
@ -240,6 +232,30 @@ main(void)
|
||||
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);
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user