From d6f4734adf504e6efb40e4331c723a52345bdc2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 27 Apr 2022 20:33:40 +0200 Subject: notify-send: Add support for boolean hints Boolean hints are used for some common parameters such as "transient". Original bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=636343 --- docs/notify-send.xml | 2 +- tools/notify-send.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/notify-send.xml b/docs/notify-send.xml index c8eb6ef..0f36fa0 100644 --- a/docs/notify-send.xml +++ b/docs/notify-send.xml @@ -101,7 +101,7 @@ , =TYPE:NAME:VALUE - Specifies basic extra data to pass. Valid types are INT, DOUBLE, STRING and BYTE. + Specifies basic extra data to pass. Valid types are BOOLEAN, INT, DOUBLE, STRING and BYTE. diff --git a/tools/notify-send.c b/tools/notify-send.c index 6214a40..8d3898d 100644 --- a/tools/notify-send.c +++ b/tools/notify-send.c @@ -100,6 +100,17 @@ notify_notification_set_hint_variant (NotifyNotification *notification, key, (guchar) h_byte); } + } else if (g_ascii_strcasecmp (type, "boolean") == 0) { + gboolean h_boolean = FALSE; + + if (g_ascii_strcasecmp (value, "true") == 0) { + h_boolean = TRUE; + } else if (g_ascii_isdigit (*value)) { + h_boolean = !!g_ascii_strtoull (value, NULL, 10); + } + + notify_notification_set_hint (notification, key, + g_variant_new_boolean (h_boolean)); } else { *error = g_error_new (G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE, @@ -197,7 +208,7 @@ main (int argc, char *argv[]) N_("TYPE[,TYPE...]")}, {"hint", 'h', 0, G_OPTION_ARG_FILENAME_ARRAY, &hints, N_ - ("Specifies basic extra data to pass. Valid types are int, double, string and byte."), + ("Specifies basic extra data to pass. Valid types are boolean, 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}, -- cgit v1.2.1