Skip to content
Snippets Groups Projects
Commit ed178bba authored by Martin Mareš's avatar Martin Mareš
Browse files

osd-batt: Warn on important status changes, too

This way, the user knows whenever he accidentally loses his AC power
or when the battery is full.
parent f7e6a0d0
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,9 @@ static int charge_time, discharge_time;
static int ac_online;
static unsigned int present_mask, charge_mask, discharge_mask;
static unsigned int last_charge_mask, last_discharge_mask;
static int last_ac_online = -1;
static char *parse_line(char *line)
{
char *t = strchr(line, '\n');
......@@ -204,8 +207,16 @@ static void show(void)
static void show_if_warn(void)
{
if (discharge_mask && discharge_time < warn_threshold)
if (discharge_mask && discharge_time < warn_threshold ||
last_ac_online >= 0 && (
charge_mask != last_charge_mask ||
discharge_mask != last_discharge_mask ||
ac_online != last_ac_online))
show();
last_charge_mask = charge_mask;
last_discharge_mask = discharge_mask;
last_ac_online = ac_online;
}
static void NONRET
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment