From bcd3a79b1c0c8ac9b8976052a089b6be609be922 Mon Sep 17 00:00:00 2001 From: progandy Date: Mon, 8 Oct 2012 12:38:53 +0200 Subject: [PATCH 1/4] document new placeholder --- README.pod | 5 +++++ dunst.h | 2 +- dunstrc | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.pod b/README.pod index ef97a75..df50551 100644 --- a/README.pod +++ b/README.pod @@ -119,6 +119,8 @@ fmt is a string containing placeholders. The placeholders will be replaced with =item B<%I> iconname (without its path) +=item B<%p> progress value if set ([ 0%] to [100%]) or nothing + =back =head1 COLORS @@ -131,6 +133,7 @@ X color names. dunst is able to get different colors for a message via notify-send. In order to do that you have to add a hint via the -h option. +The progress value can be set with a hint, too. =over 4 @@ -138,6 +141,8 @@ In order to do that you have to add a hint via the -h option. =item notify-send -h string:bgcolor:#4444ff -h string:fgcolor:#ff4444 +=item notify-send -h int:value:42 "Working ..." + =back =head1 CONFIGURATION diff --git a/dunst.h b/dunst.h index 784cb9e..5e56f23 100644 --- a/dunst.h +++ b/dunst.h @@ -54,7 +54,7 @@ typedef struct _notification { int dup_count; ColorSet *colors; char *color_strings[2]; - int progress; + int progress; /* percentage + 1, 0 to hide */ } notification; typedef struct _notification_buffer { diff --git a/dunstrc b/dunstrc index c59ae94..9955fe2 100644 --- a/dunstrc +++ b/dunstrc @@ -7,6 +7,7 @@ # %b body # %i iconname (including its path) # %I iconname (without its path) + # %p progress value if set ([ 0%] to [100%]) or nothing format = "%s %b" # Sort messages by urgency From 0e063637db47fda01a0e5b7900e42676584e460a Mon Sep 17 00:00:00 2001 From: progandy Date: Mon, 8 Oct 2012 12:39:49 +0200 Subject: [PATCH 2/4] small bugfixes --- dunst.c | 5 +++-- dunst_dbus.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dunst.c b/dunst.c index d500f21..70a1c55 100644 --- a/dunst.c +++ b/dunst.c @@ -908,11 +908,12 @@ int init_notification(notification * n, int id) n->msg = string_replace("%I", basename(n->icon), n->msg); n->msg = string_replace("%b", n->body, n->msg); if (n->progress) { - char pg[20]; + char pg[10]; sprintf(pg, "[%3d%%]", n->progress-1); n->msg = string_replace("%p", pg, n->msg); - } else + } else { n->msg = string_replace("%p", "", n->msg); + } n->msg = fix_markup(n->msg); diff --git a/dunst_dbus.c b/dunst_dbus.c index 9f8cfe5..8590af5 100644 --- a/dunst_dbus.c +++ b/dunst_dbus.c @@ -336,7 +336,7 @@ void notify(DBusMessage * dmsg) continue; } dbus_message_iter_get_basic(&hint, &hint_name); - _extract_hint(DBUS_TYPE_STRING, "urgency", hint_name, &hint, &urgency); + _extract_hint(DBUS_TYPE_BYTE, "urgency", hint_name, &hint, &urgency); _extract_hint(DBUS_TYPE_STRING, "fgcolor", hint_name, &hint, &fgcolor); _extract_hint(DBUS_TYPE_STRING, "bgcolor", hint_name, &hint, &bgcolor); _extract_hint(DBUS_TYPE_INT32, "value", hint_name, &hint, &progress); From 04c9e70484c6018de464c8431b750a08d2ace33b Mon Sep 17 00:00:00 2001 From: progandy Date: Mon, 8 Oct 2012 12:41:36 +0200 Subject: [PATCH 3/4] fix id when replacing notifications (freedesktop standard expects same id) --- dunst.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dunst.c b/dunst.c index 70a1c55..fd5ef26 100644 --- a/dunst.c +++ b/dunst.c @@ -970,7 +970,7 @@ int init_notification(notification * n, int id) n->id = ++next_notification_id; } else { close_notification_by_id(id, -1); - n->id = ++next_notification_id; + n->id = id; } if(strlen(n->msg) == 0) { From 75cb6da7f77d708205b70573c732341ef25c2c29 Mon Sep 17 00:00:00 2001 From: progandy Date: Mon, 8 Oct 2012 12:50:06 +0200 Subject: [PATCH 4/4] simplified documentation --- README.pod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.pod b/README.pod index df50551..2cf685c 100644 --- a/README.pod +++ b/README.pod @@ -119,7 +119,7 @@ fmt is a string containing placeholders. The placeholders will be replaced with =item B<%I> iconname (without its path) -=item B<%p> progress value if set ([ 0%] to [100%]) or nothing +=item B<%p> progress value ([ 0%] to [100%]) =back