From 00060edca9598685d7b1299b5be1b6adb74ab5dd Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sun, 14 Sep 2014 17:58:26 +0200 Subject: do not show notification if state did not change --- netlink-notify.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/netlink-notify.c b/netlink-notify.c index de4e184..40da52b 100644 --- a/netlink-notify.c +++ b/netlink-notify.c @@ -64,6 +64,7 @@ struct addresses_seen { struct ifs { char *name; + int state; unsigned char deleted; struct addresses_seen *addresses_seen; NotifyNotification *notification; @@ -293,6 +294,7 @@ static int msg_handler (struct sockaddr_nl *nl, struct nlmsghdr *msg) { ifs[maxinterface] = malloc(sizeof(struct ifs)); ifs[maxinterface]->name = NULL; + ifs[maxinterface]->state = -1; ifs[maxinterface]->deleted = 0; ifs[maxinterface]->notification = @@ -407,6 +409,12 @@ static int msg_handler (struct sockaddr_nl *nl, struct nlmsghdr *msg) { case RTM_DELROUTE: return 0; case RTM_NEWLINK: + /* ignore if state did not change */ + if ((ifi->ifi_flags & CHECK_CONNECTED) == ifs[ifi->ifi_index]->state) + return 0; + + ifs[ifi->ifi_index]->state = ifi->ifi_flags & CHECK_CONNECTED; + notifystr = newstr_link(TEXT_NEWLINK, ifs[ifi->ifi_index]->name, ifi->ifi_flags); icon = ifi->ifi_flags & CHECK_CONNECTED ? ICON_NETWORK_UP : ICON_NETWORK_DOWN; -- cgit v1.2.3-70-g09d2