From aadb1b22b37d9f5f41c1cb2a27970bf2e0435174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 1 May 2021 11:33:04 +0200 Subject: [PATCH] =?UTF-8?q?module/battery:=20don=E2=80=99t=20terminate=20w?= =?UTF-8?q?hen=20failing=20to=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- CHANGELOG.md | 3 +++ modules/battery.c | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8910271..f2c7f53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: don’t terminate (causing last status to “freeze”) when + failing to update; retry again later + (https://codeberg.org/dnkl/yambar/issues/44). ### Deprecated diff --git a/modules/battery.c b/modules/battery.c index 7dcfc45..7b8ff5e 100644 --- a/modules/battery.c +++ b/modules/battery.c @@ -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: