wmbattery: upower - don't exit after suspend/hibernation wakup

Immediately after suspend/hibernation wakup cycle, up_client_get_devices()
can fail:

 libupower-glib-WARNING **: up_client_get_devices failed: Timeout was reached

Since we do not interpret the UPower signals, just don't exit wmbattery after
first up_client_get_devices() failure.
This commit is contained in:
Christoph Fritz 2015-05-13 23:38:51 -05:00 committed by Carlos R. Mafra
parent a8858dedde
commit 9c6faa3682

View file

@ -9,6 +9,8 @@
#include <upower.h>
#include "apm.h"
#define MAX_RETRIES 3
static UpClient * up;
struct context {
@ -74,6 +76,7 @@ int upower_supported(void)
int upower_read(int battery, apm_info *info)
{
GPtrArray *devices = NULL;
static int retries = 0;
up = up_client_new();
@ -87,9 +90,15 @@ int upower_read(int battery, apm_info *info)
devices = up_client_get_devices(up);
if (!devices)
return -1;
if (!devices) {
retries++;
if (retries < MAX_RETRIES)
return 0; /* fine immediately after hibernation */
else
return -1;
}
retries = 0;
info->battery_flags = 0;
info->using_minutes = 0;