Merge branch 'master' of https://github.com/progandy/dunst into progress_hint

This commit is contained in:
Sascha Kruse 2012-10-08 19:00:00 +02:00
commit b28f03faf7
5 changed files with 12 additions and 5 deletions

View File

@ -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<%I> iconname (without its path)
=item B<%p> progress value ([ 0%] to [100%])
=back =back
=head1 COLORS =head1 COLORS
@ -131,6 +133,7 @@ X color names.
dunst is able to get different colors for a message via notify-send. 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. 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 =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 string:bgcolor:#4444ff -h string:fgcolor:#ff4444
=item notify-send -h int:value:42 "Working ..."
=back =back
=head1 CONFIGURATION =head1 CONFIGURATION

View File

@ -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("%I", basename(n->icon), n->msg);
n->msg = string_replace("%b", n->body, n->msg); n->msg = string_replace("%b", n->body, n->msg);
if (n->progress) { if (n->progress) {
char pg[20]; char pg[10];
sprintf(pg, "[%3d%%]", n->progress-1); sprintf(pg, "[%3d%%]", n->progress-1);
n->msg = string_replace("%p", pg, n->msg); n->msg = string_replace("%p", pg, n->msg);
} else } else {
n->msg = string_replace("%p", "", n->msg); n->msg = string_replace("%p", "", n->msg);
}
n->msg = fix_markup(n->msg); n->msg = fix_markup(n->msg);
@ -970,7 +971,7 @@ int init_notification(notification * n, int id)
n->id = ++next_notification_id; n->id = ++next_notification_id;
} else { } else {
close_notification_by_id(id, -1); close_notification_by_id(id, -1);
n->id = ++next_notification_id; n->id = id;
} }
if(strlen(n->msg) == 0) { if(strlen(n->msg) == 0) {

View File

@ -54,7 +54,7 @@ typedef struct _notification {
int dup_count; int dup_count;
ColorSet *colors; ColorSet *colors;
char *color_strings[2]; char *color_strings[2];
int progress; int progress; /* percentage + 1, 0 to hide */
} notification; } notification;
typedef struct _notification_buffer { typedef struct _notification_buffer {

View File

@ -336,7 +336,7 @@ void notify(DBusMessage * dmsg)
continue; continue;
} }
dbus_message_iter_get_basic(&hint, &hint_name); 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, "fgcolor", hint_name, &hint, &fgcolor);
_extract_hint(DBUS_TYPE_STRING, "bgcolor", hint_name, &hint, &bgcolor); _extract_hint(DBUS_TYPE_STRING, "bgcolor", hint_name, &hint, &bgcolor);
_extract_hint(DBUS_TYPE_INT32, "value", hint_name, &hint, &progress); _extract_hint(DBUS_TYPE_INT32, "value", hint_name, &hint, &progress);

View File

@ -7,6 +7,7 @@
# %b body # %b body
# %i iconname (including its path) # %i iconname (including its path)
# %I iconname (without its path) # %I iconname (without its path)
# %p progress value if set ([ 0%] to [100%]) or nothing
format = "%s %b" format = "%s %b"
# Sort messages by urgency # Sort messages by urgency