From a56e6693565068f7e8513a54e5ee8213613badd0 Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Mon, 24 Mar 2008 21:44:50 +0000 Subject: [PATCH] * Fixed battery_bar default size git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1049 7f574dfc-610e-0410-a909-a81674777703 --- ChangeLog | 3 +++ src/conky.c | 21 +++++++++++---------- src/linux.c | 22 ++++++++++++++-------- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index b6b08803..9ec7686f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ # $Id$ +2008-03-24 + * Fixed battery_bar default size + 2008-03-23 * Fixed compilation with --disable-x11 * Fixed linux.c compilation problem due to (suspected) broken linux diff --git a/src/conky.c b/src/conky.c index 65eccab3..6ab59b8a 100644 --- a/src/conky.c +++ b/src/conky.c @@ -2436,7 +2436,7 @@ static struct text_object *construct_text_object(const char *s, 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); @@ -2806,7 +2806,6 @@ static struct text_object *construct_text_object(const char *s, } #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)) { @@ -2820,16 +2819,18 @@ static struct text_object *construct_text_object(const char *s, } 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) { @@ -7360,9 +7361,9 @@ static void main_loop() 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 */ diff --git a/src/linux.c b/src/linux.c index 6a6b7707..ac0e1dbb 100644 --- a/src/linux.c +++ b/src/linux.c @@ -1468,9 +1468,9 @@ present voltage: 16608 mV #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]; @@ -1544,11 +1544,14 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item) /* 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 */ @@ -1818,7 +1821,7 @@ set_return_value: int get_battery_perct(const char *bat) { - static int rep; + static int rep = 0; int idx; char acpi_path[128]; @@ -1838,11 +1841,14 @@ int get_battery_perct(const char *bat) /* 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;