Add format string for raw progress value

While it's not the best solution, it should cover most use cases where a
custom format on the progress value is required. If any further
customization is needed, the only current alternative is to use rules
to override the format.

Closes #273
This commit is contained in:
Nikos Tsipinakis 2017-07-09 20:15:57 +03:00
parent d206f2445f
commit 44ac026d97
3 changed files with 6 additions and 0 deletions

View File

@ -319,6 +319,8 @@ equivalent notification attribute.
=item B<%p> progress value ([ 0%] to [100%])
=item B<%n> progress value without any extra characters
=back
If any of these exists in the format but hasn't been specified in the

View File

@ -121,6 +121,7 @@
# %i iconname (including its path)
# %I iconname (without its path)
# %p progress value if set ([ 0%] to [100%]) or nothing
# %n progress value if set without any extra characters
# Markup is allowed
format = "<b>%s</b>\n%b"

View File

@ -323,8 +323,11 @@ int notification_init(notification * n, int id)
char pg[10];
sprintf(pg, "[%3d%%]", n->progress - 1);
n->msg = string_replace_all("%p", pg, n->msg);
sprintf(pg, "%d", n->progress - 1);
n->msg = string_replace_all("%n", pg, n->msg);
} else {
n->msg = string_replace_all("%p", "", n->msg);
n->msg = string_replace_all("%n", "", n->msg);
}
n->msg = g_strchomp(n->msg);