mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-23 12:35:41 +02:00
module/battery: don’t crash if we fail to read from ‘status’
This commit is contained in:
parent
f49652130d
commit
4a9f550069
1 changed files with 4 additions and 1 deletions
|
@ -291,7 +291,10 @@ update_status(struct module *mod, int capacity_fd, int energy_fd, int power_fd,
|
|||
const char *status = readline_from_fd(status_fd);
|
||||
enum state state;
|
||||
|
||||
if (strcmp(status, "Full") == 0)
|
||||
if (status == NULL) {
|
||||
LOG_WARN("failed to read battery state");
|
||||
state = STATE_DISCHARGING;
|
||||
} else if (strcmp(status, "Full") == 0)
|
||||
state = STATE_FULL;
|
||||
else if (strcmp(status, "Charging") == 0)
|
||||
state = STATE_CHARGING;
|
||||
|
|
Loading…
Add table
Reference in a new issue