~kennylevinsen/poweralertd

fc612ab8fd5aa23ff70c7b837f1b2f871ff0d950 — Thomas Weißschuh 1 year, 5 months ago 3c0c7c7
feat: don't send warning when changing from unknown to no warning

When a device is added via BlueZ it is first added at warning_level
"unknown" and then changes to "none".
This triggers a spurious notification about "Warning cleared" although
no warning was ever reported.
1 files changed, 4 insertions(+), 0 deletions(-)

M main.c
M main.c => main.c +4 -0
@@ 91,6 91,10 @@ static int send_warning_update(sd_bus *bus, struct upower_device *device) {
		return 0;
	}

	if (device->current.warning_level == UPOWER_DEVICE_LEVEL_NONE && device->last.warning_level == UPOWER_DEVICE_LEVEL_UNKNOWN) {
		return 0;
	}

	enum urgency urgency = URGENCY_CRITICAL;
	char title[NOTIFICATION_MAX_LEN];
	char *msg;