diff --git a/README.pod b/README.pod index ef97a75..2cf685c 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 ([ 0%] to [100%]) + =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.c b/dunst.c index 1663c04..cdb6feb 100644 --- a/dunst.c +++ b/dunst.c @@ -909,11 +909,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); @@ -970,7 +971,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) { 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/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); 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