[libnotify/wip/notify-error-code: 9/9] notify-send: Give failing exit code if showing notification fails
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libnotify/wip/notify-error-code: 9/9] notify-send: Give failing exit code if showing notification fails
- Date: Fri, 14 May 2021 17:56:25 +0000 (UTC)
commit a228f1e84d8a1ebe2a2cc10d19900af719ed44dc
Author: Ray Strode <rstrode redhat com>
Date: Tue May 12 10:12:26 2020 -0400
notify-send: Give failing exit code if showing notification fails
Right now notify-send will quietly return a successful exit status
even if showing the notification fails.
This commit changes the behavior to instead fail on failure.
https://gitlab.gnome.org/GNOME/libnotify/-/merge_requests/13
tools/notify-send.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/tools/notify-send.c b/tools/notify-send.c
index 9b8e438..15aa164 100644
--- a/tools/notify-send.c
+++ b/tools/notify-send.c
@@ -131,7 +131,7 @@ main (int argc, char *argv[])
static char **n_text = NULL;
static char **hints = NULL;
static gboolean do_version = FALSE;
- static gboolean hint_error = FALSE;
+ static gboolean hint_error = FALSE, show_error = FALSE;
static glong expire_timeout = NOTIFY_EXPIRES_DEFAULT;
GOptionContext *opt_ctx;
NotifyNotification *notify;
@@ -263,12 +263,22 @@ main (int argc, char *argv[])
}
}
- if (!hint_error)
- notify_notification_show (notify, NULL);
+ if (!hint_error) {
+ retval = notify_notification_show (notify, &error);
+
+ if (!retval) {
+ fprintf (stderr, "%s\n", error->message);
+ g_error_free (error);
+ show_error = TRUE;
+ }
+ }
g_object_unref (G_OBJECT (notify));
notify_uninit ();
- exit (hint_error);
+ if (hint_error || show_error)
+ exit (1);
+
+ return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]