From: Ludwig Nussel <ludwig.nus...@suse.de>

* reuse dbus connection
* set delay to actually refresh values
---
 wmbattery/upower.c    | 7 +------
 wmbattery/wmbattery.c | 4 +++-
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/wmbattery/upower.c b/wmbattery/upower.c
index 857c7f4..75ba874 100644
--- a/wmbattery/upower.c
+++ b/wmbattery/upower.c
@@ -9,7 +9,7 @@
 #include <upower.h>
 #include "apm.h"
 
-int num_batteries = 0;
+static UpClient * up;
 
 struct context {
        int current;
@@ -54,7 +54,6 @@ static void get_devinfo(gpointer device, gpointer result)
 
 int upower_supported(void)
 {
-       UpClient *up;
        up = up_client_new();
 
        if (!up) {
@@ -63,11 +62,9 @@ int upower_supported(void)
                GPtrArray *devices = up_client_get_devices(up);
 
                if (!devices) {
-                       g_object_unref(up);
                        return 0;
                } else {
                        g_ptr_array_unref(devices);
-                       g_object_unref(up);
                        return 1;
                }
        }
@@ -76,7 +73,6 @@ int upower_supported(void)
 /* Fill the passed apm_info struct. */
 int upower_read(int battery, apm_info *info)
 {
-       UpClient *up;
        GPtrArray *devices = NULL;
 
        up = up_client_new();
@@ -139,6 +135,5 @@ int upower_read(int battery, apm_info *info)
        }
 
        g_ptr_array_free(devices, TRUE);
-       g_object_unref(up);
        return 0;
 }
diff --git a/wmbattery/wmbattery.c b/wmbattery/wmbattery.c
index 1d45d65..74d39fd 100644
--- a/wmbattery/wmbattery.c
+++ b/wmbattery/wmbattery.c
@@ -798,8 +798,10 @@ int main(int argc, char *argv[])
        }
 #endif
 #ifdef UPOWER
-       else if (upower_supported())
+       else if (upower_supported()) {
                use_upower = 1;
+               delay = 2;
+       }
 #endif
        /* Check for ACPI support. */
        else if (acpi_supported() && acpi_batt_count > 0) {
-- 
2.1.0


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to