obj->data.s = strdup(bat);
END OBJ(battery_bar, 0)
char bat[64];
-
+ obj->b = 6;
if (arg) {
arg = scan_bar(arg, &obj->a, &obj->b);
sscanf(arg, "%63s", bat);
}
#endif
END OBJ(fs_bar, INFO_FS)
- obj->data.fsbar.h = 4;
arg = scan_bar(arg, &obj->data.fsbar.w, &obj->data.fsbar.h);
if (arg) {
while (isspace(*arg)) {
}
obj->data.fsbar.fs = prepare_fs_stat(arg);
END OBJ(fs_bar_free, INFO_FS)
- obj->data.fsbar.h = 4;
+ arg = scan_bar(arg, &obj->data.fsbar.w, &obj->data.fsbar.h);
if (arg) {
- unsigned int n;
-
- if (sscanf(arg, "%d %n", &obj->data.fsbar.h, &n) >= 1) {
- arg += n;
+ while (isspace(*arg)) {
+ arg++;
+ }
+ if (*arg == '\0') {
+ arg = "/";
}
} else {
arg = "/";
}
+
obj->data.fsbar.fs = prepare_fs_stat(arg);
END OBJ(fs_free, INFO_FS)
if (!arg) {
XDestroyRegion(region);
region = NULL;
#ifdef HAVE_XDAMAGE
- XDamageDestroy(display, damage);
- XFixesDestroyRegion(display, region2);
- XFixesDestroyRegion(display, part);
+ XDamageDestroy(display, damage);
+ XFixesDestroyRegion(display, region2);
+ XFixesDestroyRegion(display, part);
#endif /* HAVE_XDAMAGE */
#endif /* X11 */
return; /* return from main_loop */
#define APM_PATH "/proc/apm"
#define MAX_BATTERY_COUNT 4
-static FILE *sysfs_bat_fp[MAX_BATTERY_COUNT];
-static FILE *acpi_bat_fp[MAX_BATTERY_COUNT];
-static FILE *apm_bat_fp[MAX_BATTERY_COUNT];
+static FILE *sysfs_bat_fp[MAX_BATTERY_COUNT] = { NULL, NULL, NULL, NULL };
+static FILE *acpi_bat_fp[MAX_BATTERY_COUNT] = { NULL, NULL, NULL, NULL };
+static FILE *apm_bat_fp[MAX_BATTERY_COUNT] = { NULL, NULL, NULL, NULL };
static int batteries_initialized = 0;
static char batteries[MAX_BATTERY_COUNT][32];
/* first try SYSFS if that fails try ACPI */
- if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL)
+ if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) {
sysfs_bat_fp[idx] = open_file(sysfs_path, &rep);
+ rep = 0;
+ }
- if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL)
+ if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) {
acpi_bat_fp[idx] = open_file(acpi_path, &rep);
+ }
if (sysfs_bat_fp[idx] != NULL) {
/* SYSFS */
int get_battery_perct(const char *bat)
{
- static int rep;
+ static int rep = 0;
int idx;
char acpi_path[128];
/* Only check for SYSFS or ACPI */
- if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL)
+ if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) {
sysfs_bat_fp[idx] = open_file(sysfs_path, &rep);
+ rep = 0;
+ }
- if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL)
+ if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) {
acpi_bat_fp[idx] = open_file(acpi_path, &rep);
+ }
int remaining_capacity = -1;