From 59be5d4cd51907795254f9957416f8143d004745 Mon Sep 17 00:00:00 2001 From: Sravan Balaji Date: Fri, 7 Aug 2020 22:57:51 -0400 Subject: [PATCH] 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 "|" --- components/battery.c | 9 ++++----- config.h | 4 +++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/components/battery.c b/components/battery.c index b26f1c5..b51a55a 100644 --- a/components/battery.c +++ b/components/battery.c @@ -123,11 +123,10 @@ battery_all_in_one(const char *bat) { char path[PATH_MAX]; - char *div = ""; if (esnprintf(path, sizeof(path), "/sys/class/power_supply/%s", bat) < 0) { - return bprintf(" %s ", div); + return " AC"; } DIR* dir = opendir(path); @@ -138,7 +137,7 @@ } else if (ENOENT == errno) { // Battery doesn't exist - return bprintf(" %s ", div); + return " AC"; } int percentage = atoi(battery_perc(bat)); @@ -179,7 +178,7 @@ } if (!strcmp(battery_state(bat), "+")) { - bat_status = ""; + bat_status = " "; bat_rem = ""; } else { @@ -190,7 +189,7 @@ 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__) #include diff --git a/config.h b/config.h index 7bdffec..d45e863 100644 --- a/config.h +++ b/config.h @@ -10,7 +10,7 @@ static const char unknown_str[] = "?"; #define MAXLEN 2048 static const char battery_name[] = "BAT0"; -static const char divider_symbol[] = ""; +static const char divider_symbol[] = "|"; /* * function description argument (example) @@ -77,7 +77,9 @@ static const struct arg args[] = { { ram_perc, " %s%%", NULL }, { divider, " %s ", divider_symbol }, { disk_perc, " %s%%", "/home" }, + { divider, " %s ", divider_symbol }, { battery_all_in_one, "%s", battery_name, }, + { divider, " %s ", divider_symbol }, { datetime, " %s", "%a %x" }, { divider, " %s ", divider_symbol }, { datetime, " %s", "%I:%M:%S %p" },