From fc612ab8fd5aa23ff70c7b837f1b2f871ff0d950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 7 Dec 2021 18:32:15 +0100 Subject: [PATCH] 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. --- main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.c b/main.c index 30ca4b5..20b1f25 100644 --- a/main.c +++ b/main.c @@ -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; -- 2.34.2