Icon Changes & AC Power

- Remove dividers from inside battery_all_in_one function
- When there is no battery, show plug with AC
- Change charging status symbol to plug
- Move charging status in front of battery icon
- Change divider back to "|"
This commit is contained in:
Sravan Balaji
2020-08-07 22:57:51 -04:00
parent 764813c0c1
commit 59be5d4cd5
2 changed files with 7 additions and 6 deletions

View File

@@ -123,11 +123,10 @@
battery_all_in_one(const char *bat) battery_all_in_one(const char *bat)
{ {
char path[PATH_MAX]; char path[PATH_MAX];
char *div = "";
if (esnprintf(path, sizeof(path), if (esnprintf(path, sizeof(path),
"/sys/class/power_supply/%s", bat) < 0) { "/sys/class/power_supply/%s", bat) < 0) {
return bprintf(" %s ", div); return " AC";
} }
DIR* dir = opendir(path); DIR* dir = opendir(path);
@@ -138,7 +137,7 @@
} }
else if (ENOENT == errno) { else if (ENOENT == errno) {
// Battery doesn't exist // Battery doesn't exist
return bprintf(" %s ", div); return " AC";
} }
int percentage = atoi(battery_perc(bat)); int percentage = atoi(battery_perc(bat));
@@ -179,7 +178,7 @@
} }
if (!strcmp(battery_state(bat), "+")) { if (!strcmp(battery_state(bat), "+")) {
bat_status = ""; bat_status = "";
bat_rem = ""; bat_rem = "";
} }
else { else {
@@ -190,7 +189,7 @@
sprintf(bat_rem, " (%s)", temp); sprintf(bat_rem, " (%s)", temp);
} }
return bprintf(" %s %s%s %i%%%s %s ", div, bat_icon, bat_status, percentage, bat_rem, div); return bprintf(" %s%s %i%%%s ", bat_status, bat_icon, percentage, bat_rem);
} }
#elif defined(__OpenBSD__) #elif defined(__OpenBSD__)
#include <fcntl.h> #include <fcntl.h>

View File

@@ -10,7 +10,7 @@ static const char unknown_str[] = "?";
#define MAXLEN 2048 #define MAXLEN 2048
static const char battery_name[] = "BAT0"; static const char battery_name[] = "BAT0";
static const char divider_symbol[] = ""; static const char divider_symbol[] = "|";
/* /*
* function description argument (example) * function description argument (example)
@@ -77,7 +77,9 @@ static const struct arg args[] = {
{ ram_perc, " %s%%", NULL }, { ram_perc, " %s%%", NULL },
{ divider, " %s ", divider_symbol }, { divider, " %s ", divider_symbol },
{ disk_perc, " %s%%", "/home" }, { disk_perc, " %s%%", "/home" },
{ divider, " %s ", divider_symbol },
{ battery_all_in_one, "%s", battery_name, }, { battery_all_in_one, "%s", battery_name, },
{ divider, " %s ", divider_symbol },
{ datetime, " %s", "%a %x" }, { datetime, " %s", "%a %x" },
{ divider, " %s ", divider_symbol }, { divider, " %s ", divider_symbol },
{ datetime, " %s", "%I:%M:%S %p" }, { datetime, " %s", "%I:%M:%S %p" },