module/battery: don’t terminate when failing to update

Some battery drivers will remove their sysfs directory when the
battery goes from charging to discharging, or vice verse.

This caused yambar’s battery module to terminate, resulting in the
last known battery state to “freeze”.

With this patch, failure to read the battery directory the *first*
time is still considered a hard failure, resulting in an error message
and then termination.

However, subsequent failures, i.e. while polling the battery state,
is *not* considered fatal; we simply don’t update the bar, and retry
again the next poll interval. Error messages are still logged however.

Closes #44
This commit is contained in:
Daniel Eklöf 2021-05-01 11:33:04 +02:00
parent d95023adc8
commit aadb1b22b3
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 5 additions and 3 deletions

View file

@ -20,6 +20,9 @@
* fcft >= 2.4.0 is now required.
* sway-xkb: non-keyboard inputs are now ignored
(https://codeberg.org/dnkl/yambar/issues/51).
* battery: dont terminate (causing last status to “freeze”) when
failing to update; retry again later
(https://codeberg.org/dnkl/yambar/issues/44).
### Deprecated

View file

@ -434,9 +434,8 @@ run(struct module *mod)
continue;
}
if (!update_status(mod))
break;
bar->refresh(bar);
if (update_status(mod))
bar->refresh(bar);
}
out: