coding style fixes
This commit is contained in:
parent
7710c9ed85
commit
3bfa5fe60d
17
config.def.h
17
config.def.h
|
@ -1,15 +1,15 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
|
||||||
/* alsa sound */
|
/* alsa sound */
|
||||||
#define ALSA_CHANNEL "Master"
|
#define ALSA_CHANNEL "Master"
|
||||||
|
|
||||||
/* battery */
|
/* battery */
|
||||||
#define BATTERY_PATH "/sys/class/power_supply/"
|
#define BATTERY_PATH "/sys/class/power_supply/"
|
||||||
#define BATTERY_NOW "energy_now"
|
#define BATTERY_NOW "energy_now"
|
||||||
#define BATTERY_FULL "energy_full_design"
|
#define BATTERY_FULL "energy_full_design"
|
||||||
|
|
||||||
/* text to show if no value can be retrieved */
|
/* text to show if no value can be retrieved */
|
||||||
#define UNKNOWN_STR "n/a"
|
#define UNKNOWN_STR "n/a"
|
||||||
|
|
||||||
/* statusbar
|
/* statusbar
|
||||||
- battery_perc (battery percentage) [argument: battery name]
|
- battery_perc (battery percentage) [argument: battery name]
|
||||||
|
@ -38,8 +38,7 @@
|
||||||
- wifi_essid (wifi essid) [argument: wifi card interface name] */
|
- wifi_essid (wifi essid) [argument: wifi card interface name] */
|
||||||
static const struct arg args[] = {
|
static const struct arg args[] = {
|
||||||
/* function format argument */
|
/* function format argument */
|
||||||
{ cpu_perc, "[ CPU %4s ]", NULL },
|
{ cpu_perc, "[ CPU %4s ]", NULL },
|
||||||
{ ram_perc, "[ Mem %3s ]", NULL },
|
{ ram_perc, "[ Mem %3s ]", NULL },
|
||||||
{ disk_perc, "[ HDD %3s ]", "/" },
|
{ datetime, "[ %s ]", "%F %T" },
|
||||||
{ datetime, "[ %s ]", "%F %T" },
|
|
||||||
};
|
};
|
||||||
|
|
12
slstatus.c
12
slstatus.c
|
@ -150,6 +150,7 @@ cpu_perc(void)
|
||||||
fscanf(fp, "%*s %Lf %Lf %Lf %Lf", &b[0], &b[1], &b[2], &b[3]);
|
fscanf(fp, "%*s %Lf %Lf %Lf %Lf", &b[0], &b[1], &b[2], &b[3]);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
perc = 100 * ((b[0]+b[1]+b[2]) - (a[0]+a[1]+a[2])) / ((b[0]+b[1]+b[2]+b[3]) - (a[0]+a[1]+a[2]+a[3]));
|
perc = 100 * ((b[0]+b[1]+b[2]) - (a[0]+a[1]+a[2])) / ((b[0]+b[1]+b[2]+b[3]) - (a[0]+a[1]+a[2]+a[3]));
|
||||||
|
|
||||||
return smprintf("%d%%", perc);
|
return smprintf("%d%%", perc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +176,7 @@ disk_free(const char *mountpoint)
|
||||||
warn("Could not get filesystem info");
|
warn("Could not get filesystem info");
|
||||||
return smprintf(UNKNOWN_STR);
|
return smprintf(UNKNOWN_STR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return smprintf("%f", (float)fs.f_bsize * (float)fs.f_bfree / 1024 / 1024 / 1024);
|
return smprintf("%f", (float)fs.f_bsize * (float)fs.f_bfree / 1024 / 1024 / 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,6 +192,7 @@ disk_perc(const char *mountpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
perc = 100 * (1.0f - ((float)fs.f_bfree / (float)fs.f_blocks));
|
perc = 100 * (1.0f - ((float)fs.f_bfree / (float)fs.f_blocks));
|
||||||
|
|
||||||
return smprintf("%d%%", perc);
|
return smprintf("%d%%", perc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,6 +235,7 @@ entropy(void)
|
||||||
|
|
||||||
fscanf(fp, "%d", &entropy);
|
fscanf(fp, "%d", &entropy);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
return smprintf("%d", entropy);
|
return smprintf("%d", entropy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,6 +261,7 @@ hostname(void)
|
||||||
memset(&hostname[strlen(hostname)-1], '\0',
|
memset(&hostname[strlen(hostname)-1], '\0',
|
||||||
sizeof(hostname) - strlen(hostname));
|
sizeof(hostname) - strlen(hostname));
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
return smprintf("%s", hostname);
|
return smprintf("%s", hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,6 +326,7 @@ ram_free(void)
|
||||||
|
|
||||||
fscanf(fp, "MemFree: %ld kB\n", &free);
|
fscanf(fp, "MemFree: %ld kB\n", &free);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
return smprintf("%f", (float)free / 1024 / 1024);
|
return smprintf("%f", (float)free / 1024 / 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,6 +349,7 @@ ram_perc(void)
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
perc = 100 * ((total - free) - (buffers + cached)) / total;
|
perc = 100 * ((total - free) - (buffers + cached)) / total;
|
||||||
|
|
||||||
return smprintf("%d%%", perc);
|
return smprintf("%d%%", perc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,6 +366,7 @@ ram_total(void)
|
||||||
|
|
||||||
fscanf(fp, "MemTotal: %ld kB\n", &total);
|
fscanf(fp, "MemTotal: %ld kB\n", &total);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
return smprintf("%f", (float)total / 1024 / 1024);
|
return smprintf("%f", (float)total / 1024 / 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,6 +388,7 @@ ram_used(void)
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
used = total - free - buffers - cached;
|
used = total - free - buffers - cached;
|
||||||
|
|
||||||
return smprintf("%f", (float)used / 1024 / 1024);
|
return smprintf("%f", (float)used / 1024 / 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,6 +414,7 @@ run_command(const char* command)
|
||||||
}
|
}
|
||||||
if (good)
|
if (good)
|
||||||
buffer[strlen(buffer)-1] = '\0';
|
buffer[strlen(buffer)-1] = '\0';
|
||||||
|
|
||||||
return smprintf("%s", buffer);
|
return smprintf("%s", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,6 +431,7 @@ temp(const char *file)
|
||||||
|
|
||||||
fscanf(fp, "%d", &temperature);
|
fscanf(fp, "%d", &temperature);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
return smprintf("%d°C", temperature / 1000);
|
return smprintf("%d°C", temperature / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,6 +543,7 @@ wifi_perc(const char *wificard)
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
return smprintf("%d%%", strength);
|
return smprintf("%d%%", strength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue