From c692d222d737a6a391fb67ccc2ffc801b484e2f0 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Thu, 6 Sep 2018 08:36:28 +0200 Subject: [PATCH] Save the notification's scriptrun in script_run field --- src/notification.c | 7 +++++++ src/notification.h | 4 ++++ src/queues.c | 5 +---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/notification.c b/src/notification.c index 6d609cc..badd82b 100644 --- a/src/notification.c +++ b/src/notification.c @@ -92,6 +92,11 @@ void notification_run_script(notification *n) if (!n->script || strlen(n->script) < 1) return; + if (n->script_run && !settings.always_run_script) + return; + + n->script_run = true; + const char *appname = n->appname ? n->appname : ""; const char *summary = n->summary ? n->summary : ""; const char *body = n->body ? n->body : ""; @@ -268,6 +273,8 @@ notification *notification_create(void) n->transient = false; n->progress = -1; + n->script_run = false; + n->fullscreen = FS_SHOW; return n; diff --git a/src/notification.h b/src/notification.h index ab21e3c..74ddcb6 100644 --- a/src/notification.h +++ b/src/notification.h @@ -77,6 +77,7 @@ typedef struct _notification { int dup_count; /**< amount of duplicate notifications stacked onto this */ int displayed_height; enum behavior_fullscreen fullscreen; //!< The instruction what to do with it, when desktop enters fullscreen + bool script_run; /**< Has the script been executed already? */ /* derived fields */ char *msg; /**< formatted message */ @@ -139,6 +140,9 @@ int notification_is_duplicate(const notification *a, const notification *b); /** * Run the script associated with the * given notification. + * + * If the script of the notification has been executed already and + * settings.always_run_script is not set, do nothing. */ void notification_run_script(notification *n); /** diff --git a/src/queues.c b/src/queues.c index b737eb7..017a4f4 100644 --- a/src/queues.c +++ b/src/queues.c @@ -374,10 +374,7 @@ void queues_update(bool fullscreen) } n->start = time_monotonic_now(); - - if (!n->redisplayed && n->script) { - notification_run_script(n); - } + notification_run_script(n); g_queue_delete_link(waiting, iter); g_queue_insert_sorted(displayed, n, notification_cmp_data, NULL);