static int capacity;
static int ac_online = false;
static const char battery[] = "BAT0";
-static const char ac[] = "AC0";
static const char ac_acpi_dir_base[] = "/sys/class/power_supply";
static const char battery_acpi_dir_base[] = "/sys/class/power_supply";
{
char path[256];
- sprintf(path, "%s/%s/online", ac_acpi_dir_base, ac);
+ sprintf(path, "%s/%s/online", ac_acpi_dir_base, "AC");
if (access(path, F_OK ) < 0) {
- perror(path);
- fprintf(stderr,
- "Unable to find power supply AC online status.\n");
- exit(EXIT_FAILURE);
+ sprintf(path, "%s/%s/online", ac_acpi_dir_base, "AC0");
+
+ if (access(path, F_OK ) < 0) {
+ perror(path);
+ fprintf(stderr,
+ "Unable to find power supply AC online status.\n");
+ exit(EXIT_FAILURE);
+ }
}
ac_online = read_int_from_file(path);