Add multiple clocks

This commit is contained in:
Przemek Grondek 2023-02-17 23:55:55 +01:00
parent cd487dcf76
commit d4f3f221cb

View File

@ -20,6 +20,7 @@
char *tzargentina = "America/Buenos_Aires";
char *tzutc = "UTC";
char *tzwarsaw = "Europe/Warsaw";
char *tzlocal = "Australia/Sydney";
static Display *dpy;
@ -71,7 +72,7 @@ mktimes(char *fmt, char *tzname)
return smprintf("");
}
return smprintf("📅 %s", buf);
return smprintf("%s", buf);
}
void
@ -233,27 +234,35 @@ gettemperature(char *base, char *sensor)
void update() {
char *status;
char *avgs;
char *tmbln;
char *home_time;
char *local_time;
char *t0;
char *bat;
char *brightness;
char *powerConsumption;
avgs = loadavg();
tmbln = mktimes("%H:%M %d.%m.%Y", tzwarsaw);
home_time = mktimes("%H:%M", tzwarsaw);
local_time = mktimes("%H:%M %d.%m.%Y", tzlocal);
t0 = gettemperature("/sys/class//hwmon/hwmon1", "temp1_input");
bat = getbattery("/sys/class/power_supply/BAT0");
brightness = getBrightness("/sys/class/backlight/amdgpu_bl0");
powerConsumption = getPowerConsumption("/sys/class/power_supply/BAT0/power_now");
if (strcmp(tzwarsaw, tzlocal) == 0) {
status = smprintf("%s%s%s%s%s%s",
powerConsumption, bat, brightness, t0, avgs, tmbln);
powerConsumption, bat, brightness, t0, avgs, local_time);
} else {
status = smprintf("%s%s%s%s%s%s %s",
powerConsumption, bat, brightness, t0, avgs, home_time, local_time);
}
setstatus(status);
free(t0);
free(bat);
free(avgs);
free(tmbln);
free(home_time);
free(local_time);
free(status);
free(brightness);
}