|
|
|
@ -13,6 +13,14 @@ |
|
|
|
#include <limits.h> |
|
|
|
#include <linux/wireless.h> |
|
|
|
|
|
|
|
static const char col_blue[] = "#458588"; |
|
|
|
static const char col_dark[] = "#3c3836"; |
|
|
|
static const char col_gray[] = "#928374"; |
|
|
|
static const char col_green[] = "#b8bb26"; |
|
|
|
static const char col_orange[] = "#fe8019"; |
|
|
|
static const char col_red[] = "#fb4934"; |
|
|
|
static const char col_yellow[] = "#fabd2f"; |
|
|
|
|
|
|
|
const char *battery_state(const char *); |
|
|
|
|
|
|
|
const char * |
|
|
|
@ -23,28 +31,33 @@ |
|
|
|
char path[PATH_MAX]; |
|
|
|
const char *state; |
|
|
|
const char *colors[] = { |
|
|
|
"^c#ff0000^", |
|
|
|
"^c#ff8800^", |
|
|
|
"^c#ddff00^", |
|
|
|
"^c#00ff00^", |
|
|
|
"^c#00ff00^", /* Just in case the battery report a charge over 100% */ |
|
|
|
"^c#0000ff^", /* Full charge color */ |
|
|
|
"^c#888888^" |
|
|
|
col_red, |
|
|
|
col_orange, |
|
|
|
col_yellow, |
|
|
|
col_green, |
|
|
|
col_green, /* Just in case the battery report a charge over 100% */ |
|
|
|
col_blue, /* Full charge color */ |
|
|
|
col_gray |
|
|
|
}; |
|
|
|
const char *elicon = "^c#000000^^r7,6,9,3^^r10,9,9,3^^c#ffffff^^r8,7,7,1^^r13,8,1,1^^r12,9,1,1^^r11,10,7,1^"; |
|
|
|
const char *bat_icon = "^r0,7,2,4^^r2,4,22,10^^c#000000^^r3,5,20,8^%s^r%d,5,%d,8^%s^d^^f24^"; |
|
|
|
const char *elicon = "^c#3c3836^^r8,7,7,1^^r13,8,1,1^^r12,9,1,1^^r11,10,7,1^"; |
|
|
|
const char *bat_icon = "^c%s^^r0,0,36,19^^f6^^c%s^^r0,7,2,4^^r2,3,21,12^^c%s^^r4,5,17,8^^c%s^^r%d,6,%d,6^%s^d^^f30^"; |
|
|
|
|
|
|
|
snprintf(path, sizeof(path), "%s%s%s", "/sys/class/power_supply/", bat, "/capacity"); |
|
|
|
if (pscanf(path, "%i", &perc) != 1) |
|
|
|
return NULL; |
|
|
|
|
|
|
|
state = battery_state(bat); |
|
|
|
if (!strcmp(state, "?")) |
|
|
|
if (perc > 100) { |
|
|
|
perc = 100; |
|
|
|
c = 6; |
|
|
|
} else if (!strcmp(state, "?")) { |
|
|
|
c = 5; |
|
|
|
else |
|
|
|
} else { |
|
|
|
c = perc / 25; |
|
|
|
} |
|
|
|
|
|
|
|
return (bprintf(bat_icon, colors[c], 3 + 20 - perc/5, perc/5, strcmp(state,"+") ? "" : elicon)); |
|
|
|
return (bprintf(bat_icon, colors[c], col_dark, colors[c], col_dark, |
|
|
|
4 + 16 - perc * 16 / 100, perc * 16 / 100, strcmp(state,"+") ? "" : elicon)); |
|
|
|
} |
|
|
|
|
|
|
|
const char * |
|
|
|
@ -76,14 +89,20 @@ |
|
|
|
char status[5]; |
|
|
|
FILE *fp; |
|
|
|
const char *colors[5] = { |
|
|
|
"^c#ff0000^", |
|
|
|
"^c#ff8800^", |
|
|
|
"^c#ddff00^", |
|
|
|
"^c#00ff00^", |
|
|
|
"^c#00ff00^", /* Just in case the value is over 100% */ |
|
|
|
col_red, |
|
|
|
col_orange, |
|
|
|
col_yellow, |
|
|
|
col_green, |
|
|
|
col_green, /* Just in case the value is over 100% */ |
|
|
|
}; |
|
|
|
const char *bars[] = { |
|
|
|
"^r0,12,2,3^", |
|
|
|
"^r3,9,2,6^", |
|
|
|
"^r6,6,2,9^", |
|
|
|
"^r9,3,2,12^" |
|
|
|
}; |
|
|
|
const char *defc = "^c#888888^"; |
|
|
|
const char *wifi_icon = "%s^r0,11,2,3^%s^r3,8,2,6^%s^r6,5,2,9^%s^r9,2,2,12^^f12^^d^"; |
|
|
|
const char *wifi_icon = "^c%s^^r0,0,36,19^^f12^^c%s^%s%s%s%s^f24^^d^"; |
|
|
|
|
|
|
|
if (esnprintf(path, sizeof(path), "/sys/class/net/%s/operstate", iface) < 0) { |
|
|
|
return NULL; |
|
|
|
@ -122,6 +141,6 @@ |
|
|
|
|
|
|
|
/* 70 is the max of /proc/net/wireless */ |
|
|
|
cur = (int)((float)cur / 70 * 100); |
|
|
|
return bprintf(wifi_icon, colors[cur/25], cur > 25 ? "" : defc, cur > 50 ? "" : defc, cur > 75 ? "" : defc); |
|
|
|
return bprintf(wifi_icon, colors[cur/25], col_dark, bars[0], cur > 25 ? bars[1] : "", cur > 50 ? bars[2] : "", cur > 75 ? bars[3] : ""); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|