Customize status bar
This commit is contained in:
parent
81cdc8f4a2
commit
46f35713b6
47
dwmstatus.c
47
dwmstatus.c
|
@ -135,7 +135,7 @@ getbattery(char *base)
|
||||||
|
|
||||||
co = readfile(base, "charge_full_design");
|
co = readfile(base, "charge_full_design");
|
||||||
if (co == NULL) {
|
if (co == NULL) {
|
||||||
co = readfile(base, "energy_full_design");
|
co = readfile(base, "energy_full");
|
||||||
if (co == NULL)
|
if (co == NULL)
|
||||||
return smprintf("");
|
return smprintf("");
|
||||||
}
|
}
|
||||||
|
@ -156,17 +156,23 @@ getbattery(char *base)
|
||||||
status = '-';
|
status = '-';
|
||||||
} else if(!strncmp(co, "Charging", 8)) {
|
} else if(!strncmp(co, "Charging", 8)) {
|
||||||
status = '+';
|
status = '+';
|
||||||
|
} else if(!strncmp(co, "Full", 4)) {
|
||||||
|
status = ' ';
|
||||||
} else {
|
} else {
|
||||||
status = '?';
|
status = '?';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remcap < 0 || descap < 0)
|
if (remcap < 0 || descap < 0)
|
||||||
return smprintf("invalid");
|
return smprintf("invalid");
|
||||||
|
|
||||||
|
if (status == ' ') {
|
||||||
|
return smprintf("%.0f%%", ((float)remcap / (float)descap) * 100);
|
||||||
|
}
|
||||||
|
|
||||||
return smprintf("%.0f%%%c", ((float)remcap / (float)descap) * 100, status);
|
return smprintf("%.0f%%%c", ((float)remcap / (float)descap) * 100, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
int
|
||||||
gettemperature(char *base, char *sensor)
|
gettemperature(char *base, char *sensor)
|
||||||
{
|
{
|
||||||
char *co;
|
char *co;
|
||||||
|
@ -174,7 +180,8 @@ gettemperature(char *base, char *sensor)
|
||||||
co = readfile(base, sensor);
|
co = readfile(base, sensor);
|
||||||
if (co == NULL)
|
if (co == NULL)
|
||||||
return smprintf("");
|
return smprintf("");
|
||||||
return smprintf("%02.0f°C", atof(co) / 1000);
|
return atof(co) / 1000;
|
||||||
|
// return smprintf("%02.0f°C", atof(co) / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
@ -207,8 +214,8 @@ main(void)
|
||||||
char *tmar;
|
char *tmar;
|
||||||
char *tmutc;
|
char *tmutc;
|
||||||
char *tmbln;
|
char *tmbln;
|
||||||
char *t0;
|
int t0;
|
||||||
char *t1;
|
int t1;
|
||||||
char *kbmap;
|
char *kbmap;
|
||||||
char *surfs;
|
char *surfs;
|
||||||
|
|
||||||
|
@ -220,27 +227,25 @@ main(void)
|
||||||
for (;;sleep(30)) {
|
for (;;sleep(30)) {
|
||||||
avgs = loadavg();
|
avgs = loadavg();
|
||||||
bat = getbattery("/sys/class/power_supply/BAT0");
|
bat = getbattery("/sys/class/power_supply/BAT0");
|
||||||
tmar = mktimes("%H:%M", tzargentina);
|
// tmar = mktimes("%H:%M", tzargentina);
|
||||||
tmutc = mktimes("%H:%M", tzutc);
|
// tmutc = mktimes("%H:%M", tzutc);
|
||||||
tmbln = mktimes("KW %W %a %d %b %H:%M %Z %Y", tzberlin);
|
tmbln = mktimes("%a %d %b %H:%M %Z %Y", tzberlin);
|
||||||
kbmap = execscript("setxkbmap -query | grep layout | cut -d':' -f 2- | tr -d ' '");
|
// kbmap = execscript("setxkbmap -query | grep layout | cut -d':' -f 2- | tr -d ' '");
|
||||||
surfs = execscript("surf-status");
|
// surfs = execscript("surf-status");
|
||||||
t0 = gettemperature("/sys/devices/virtual/thermal/thermal_zone0", "temp");
|
t0 = gettemperature("/sys/devices/virtual/thermal/thermal_zone0", "temp");
|
||||||
t1 = gettemperature("/sys/devices/virtual/thermal/thermal_zone1", "temp");
|
t1 = gettemperature("/sys/devices/virtual/thermal/thermal_zone1", "temp");
|
||||||
|
|
||||||
status = smprintf("S:%s K:%s T:%s|%s L:%s B:%s A:%s U:%s %s",
|
status = smprintf("| T%d°C | L%s | B%s | %s |", t0 > t1 ? t0 : t1, avgs, bat, tmbln);
|
||||||
surfs, kbmap, t0, t1, avgs, bat, tmar, tmutc,
|
|
||||||
tmbln);
|
|
||||||
setstatus(status);
|
setstatus(status);
|
||||||
|
|
||||||
free(surfs);
|
// free(surfs);
|
||||||
free(kbmap);
|
// free(kbmap);
|
||||||
free(t0);
|
// free(t0);
|
||||||
free(t1);
|
// free(t1);
|
||||||
free(avgs);
|
free(avgs);
|
||||||
free(bat);
|
free(bat);
|
||||||
free(tmar);
|
// free(tmar);
|
||||||
free(tmutc);
|
// free(tmutc);
|
||||||
free(tmbln);
|
free(tmbln);
|
||||||
free(status);
|
free(status);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue