X-Git-Url: https://git.xinqibao.xyz/slstatus.git/blobdiff_plain/f3178199848911c8fb51b30e3993ae47120fcc6c..74891945d897530b30c2c29844808d63bff625b7:/components/battery.c diff --git a/components/battery.c b/components/battery.c index 3965e8f..90e8590 100644 --- a/components/battery.c +++ b/components/battery.c @@ -22,7 +22,7 @@ const char * battery_state(const char *bat) { - struct { + static struct { char *state; char *symbol; } map[] = { @@ -121,8 +121,6 @@ const char * battery_state(const char *unused) { - struct apm_power_info apm_info; - size_t i; struct { unsigned int state; char *symbol; @@ -130,6 +128,8 @@ { APM_AC_ON, "+" }, { APM_AC_OFF, "-" }, }; + struct apm_power_info apm_info; + size_t i; if (load_apm_power_info(&apm_info)) { for (i = 0; i < LEN(map); i++) {