Blame SOURCES/0001-notify-send-Give-failing-exit-code-if-showing-notifi.patch

626297
From d530d52df61731f1e36071a89e4d2a8719a3cfbf Mon Sep 17 00:00:00 2001
626297
From: Ray Strode <rstrode@redhat.com>
626297
Date: Tue, 12 May 2020 10:12:26 -0400
626297
Subject: [PATCH] notify-send: Give failing exit code if showing notification
626297
 fails
626297
626297
Right now notify-send will quietly return a successful exit status
626297
even if showing the notification fails.
626297
626297
This commit changes the behavior to instead fail on failure.
626297
626297
https://gitlab.gnome.org/GNOME/libnotify/-/merge_requests/13
626297
---
626297
 tools/notify-send.c | 18 ++++++++++++++----
626297
 1 file changed, 14 insertions(+), 4 deletions(-)
626297
626297
diff --git a/tools/notify-send.c b/tools/notify-send.c
626297
index c0b9eeb..f8d59de 100644
626297
--- a/tools/notify-send.c
626297
+++ b/tools/notify-send.c
626297
@@ -104,61 +104,61 @@ notify_notification_set_hint_variant (NotifyNotification *notification,
626297
                                       N_("Invalid hint type \"%s\". Valid types "
626297
                                          "are int, double, string and byte."),
626297
                                       type);
626297
                 return FALSE;
626297
         }
626297
 
626297
         if (conv_error) {
626297
                 *error = g_error_new (G_OPTION_ERROR,
626297
                                       G_OPTION_ERROR_BAD_VALUE,
626297
                                       N_("Value \"%s\" of hint \"%s\" could not be "
626297
                                          "parsed as type \"%s\"."), value, key,
626297
                                       type);
626297
                 return FALSE;
626297
         }
626297
 
626297
         return TRUE;
626297
 }
626297
 
626297
 int
626297
 main (int argc, char *argv[])
626297
 {
626297
         static const char  *summary = NULL;
626297
         char               *body;
626297
         static const char  *type = NULL;
626297
         static char        *app_name = NULL;
626297
         static char        *icon_str = NULL;
626297
         static char        *icons = NULL;
626297
         static char       **n_text = NULL;
626297
         static char       **hints = NULL;
626297
         static gboolean     do_version = FALSE;
626297
-        static gboolean     hint_error = FALSE;
626297
+        static gboolean     hint_error = FALSE, show_error = FALSE;
626297
         static glong        expire_timeout = NOTIFY_EXPIRES_DEFAULT;
626297
         GOptionContext     *opt_ctx;
626297
         NotifyNotification *notify;
626297
         GError             *error = NULL;
626297
         gboolean            retval;
626297
 
626297
         static const GOptionEntry entries[] = {
626297
                 {"urgency", 'u', 0, G_OPTION_ARG_CALLBACK,
626297
                  g_option_arg_urgency_cb,
626297
                  N_("Specifies the urgency level (low, normal, critical)."),
626297
                  N_("LEVEL")},
626297
                 {"expire-time", 't', 0, G_OPTION_ARG_INT, &expire_timeout,
626297
                  N_
626297
                  ("Specifies the timeout in milliseconds at which to expire the "
626297
                   "notification."), N_("TIME")},
626297
                 {"app-name", 'a', 0, G_OPTION_ARG_STRING, &app_name,
626297
                  N_("Specifies the app name for the icon"), N_("APP_NAME")},
626297
                 {"icon", 'i', 0, G_OPTION_ARG_FILENAME, &icons,
626297
                  N_("Specifies an icon filename or stock icon to display."),
626297
                  N_("ICON[,ICON...]")},
626297
                 {"category", 'c', 0, G_OPTION_ARG_FILENAME, &type,
626297
                  N_("Specifies the notification category."),
626297
                  N_("TYPE[,TYPE...]")},
626297
                 {"hint", 'h', 0, G_OPTION_ARG_FILENAME_ARRAY, &hints,
626297
                  N_
626297
                  ("Specifies basic extra data to pass. Valid types are int, double, string and byte."),
626297
                  N_("TYPE:NAME:VALUE")},
626297
                 {"version", 'v', 0, G_OPTION_ARG_NONE, &do_version,
626297
                  N_("Version of the package."),
626297
                  NULL},
626297
@@ -242,39 +242,49 @@ main (int argc, char *argv[])
626297
 
626297
                 while ((hint = hints[i++])) {
626297
                         tokens = g_strsplit (hint, ":", -1);
626297
                         l = g_strv_length (tokens);
626297
 
626297
                         if (l != 3) {
626297
                                 fprintf (stderr, "%s\n",
626297
                                          N_("Invalid hint syntax specified. "
626297
                                             "Use TYPE:NAME:VALUE."));
626297
                                 hint_error = TRUE;
626297
                         } else {
626297
                                 retval = notify_notification_set_hint_variant (notify,
626297
                                                                                tokens[0],
626297
                                                                                tokens[1],
626297
                                                                                tokens[2],
626297
                                                                                &error);
626297
 
626297
                                 if (!retval) {
626297
                                         fprintf (stderr, "%s\n", error->message);
626297
                                         g_error_free (error);
626297
                                         hint_error = TRUE;
626297
                                 }
626297
                         }
626297
 
626297
                         g_strfreev (tokens);
626297
                         if (hint_error)
626297
                                 break;
626297
                 }
626297
         }
626297
 
626297
-        if (!hint_error)
626297
-                notify_notification_show (notify, NULL);
626297
+        if (!hint_error) {
626297
+                retval = notify_notification_show (notify, &error);
626297
+
626297
+                if (!retval) {
626297
+                        fprintf (stderr, "%s\n", error->message);
626297
+                        g_error_free (error);
626297
+                        show_error = TRUE;
626297
+                }
626297
+        }
626297
 
626297
         g_object_unref (G_OBJECT (notify));
626297
 
626297
         notify_uninit ();
626297
 
626297
-        exit (hint_error);
626297
+        if (hint_error || show_error)
626297
+                exit (1);
626297
+
626297
+        return 0;
626297
 }
626297
-- 
626297
2.32.0
626297