summaryrefslogtreecommitdiff
path: root/slstatus.c
diff options
context:
space:
mode:
authorAaron Marcher <info@nulltime.net>2016-09-13 21:05:49 +0200
committerAaron Marcher (drkhsh) <info@nulltime.net>2016-09-13 21:05:49 +0200
commit74b6e340f2be27f82b4dcfc95fab47cbc0a5843b (patch)
treeba0afeadd73b2db55760982b4da5678a3144bb10 /slstatus.c
parent2d1bbf0d35f096803a96afbc8ae89a057e646d9f (diff)
lol, battery_perc() is even simpler, fuck this shit :D
Diffstat (limited to 'slstatus.c')
-rw-r--r--slstatus.c29
1 files changed, 6 insertions, 23 deletions
diff --git a/slstatus.c b/slstatus.c
index bf3c826..f61e987 100644
--- a/slstatus.c
+++ b/slstatus.c
@@ -98,36 +98,19 @@ smprintf(const char *fmt, ...)
static char *
battery_perc(const char *battery)
{
- int now, full;
+ int perc;
FILE *fp;
- ccat(3, "/sys/class/power_supply/", battery, "/energy_now");
- fp = fopen(concat, "r");
- if (fp == NULL) {
- ccat(4, "/sys/class/power_supply/", battery, "/charge_now");
- fp = fopen(concat, "r");
- if (fp == NULL) {
- warn("Error opening battery file: %s", concat);
- return smprintf(UNKNOWN_STR);
- }
- }
- fscanf(fp, "%i", &now);
- fclose(fp);
-
- ccat(3, "/sys/class/power_supply/", battery, "/energy_full");
+ ccat(3, "/sys/class/power_supply/", battery, "/capacity");
fp = fopen(concat, "r");
if (fp == NULL) {
- ccat(4, "/sys/class/power_supply/", battery, "/charge_full");
- fp = fopen(concat, "r");
- if (fp == NULL) {
- warn("Error opening battery file: %s", concat);
- return smprintf(UNKNOWN_STR);
- }
+ warn("Error opening battery file: %s", concat);
+ return smprintf(UNKNOWN_STR);
}
- fscanf(fp, "%i", &full);
+ fscanf(fp, "%i", &perc);
fclose(fp);
- return smprintf("%d%%", now / (full / 100));
+ return smprintf("%d%%", perc);
}
static char *