From 652b4d6911e95adba15d3efddce08364a925877a Mon Sep 17 00:00:00 2001 From: Paul Collins Date: Tue, 22 May 2012 13:26:08 +0200 Subject: [PATCH 1/2] notify-send: Support for replacing an existing notification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support printing and overriding notification ID, so that it's possible to replace a notification that is currently showing with an updated content. Based on patch as provided by Paul Collins in the following bug report: https://bugs.launchpad.net/ubuntu/+source/libnotify/+bug/257135/comments/8 Co-authored-by: Marco Trevisan (TreviƱo) Fixes #19 --- tools/notify-send.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/notify-send.c b/tools/notify-send.c index 15aa164..937fb41 100644 --- a/tools/notify-send.c +++ b/tools/notify-send.c @@ -130,6 +130,8 @@ main (int argc, char *argv[]) static char *icon_str = NULL; static char **n_text = NULL; static char **hints = NULL; + static gboolean print_id = FALSE; + static gint notification_id = 0; static gboolean do_version = FALSE; static gboolean hint_error = FALSE, show_error = FALSE; static glong expire_timeout = NOTIFY_EXPIRES_DEFAULT; @@ -159,6 +161,10 @@ main (int argc, char *argv[]) N_ ("Specifies basic extra data to pass. Valid types are int, double, string and byte."), N_("TYPE:NAME:VALUE")}, + {"print-id", 'p', 0, G_OPTION_ARG_NONE, &print_id, + N_ ("Print the notification ID."), NULL}, + {"replace-id", 'r', 0, G_OPTION_ARG_INT, ¬ification_id, + N_ ("The ID of the notification to replace."), N_("REPLACE_ID")}, {"version", 'v', 0, G_OPTION_ARG_NONE, &do_version, N_("Version of the package."), NULL}, @@ -217,9 +223,13 @@ main (int argc, char *argv[]) if (!notify_init ("notify-send")) exit (1); - notify = notify_notification_new (summary, - body, - icon_str); + notify = g_object_new (NOTIFY_TYPE_NOTIFICATION, + "summary", summary, + "body", body, + "icon-name", icon_str, + "id", notification_id, + NULL); + notify_notification_set_category (notify, type); notify_notification_set_urgency (notify, urgency); notify_notification_set_timeout (notify, expire_timeout); @@ -273,6 +283,11 @@ main (int argc, char *argv[]) } } + if (print_id) { + g_object_get (notify, "id", ¬ification_id, NULL); + g_printf ("%d\n", notification_id); + } + g_object_unref (G_OBJECT (notify)); notify_uninit (); From 00a7e747746e889e70245d588f03d6297c89ec0a Mon Sep 17 00:00:00 2001 From: Matthias Sweertvaegher <46206-matthias.sweertvaegher@users.noreply.gitlab.gnome.org> Date: Mon, 14 Dec 2020 16:55:07 +0100 Subject: [PATCH 2/2] docs/notify-send: Add print/replace-id arguments to man page --- docs/notify-send.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/notify-send.xml b/docs/notify-send.xml index 9c0c11b..e2c4b1d 100644 --- a/docs/notify-send.xml +++ b/docs/notify-send.xml @@ -92,6 +92,18 @@ Specifies basic extra data to pass. Valid types are INT, DOUBLE, STRING and BYTE. + + , + + Print the notification ID. + + + + , =REPLACE_ID + + The ID of the notification to replace. + +