Add support for transistent hints
This commit is contained in:
parent
3c257eaeb7
commit
585f0f85e0
@ -5,6 +5,9 @@
|
||||
### Fixed
|
||||
- `new_icon` rule being ignored on notifications that had a raw icon
|
||||
|
||||
## Changed
|
||||
- transient hints are now handled
|
||||
|
||||
## 1.2.0 - 2017-07-12
|
||||
|
||||
### Added
|
||||
|
@ -234,6 +234,8 @@ Don't timeout notifications if user is idle longer than this value (in seconds).
|
||||
|
||||
Set to 0 to disable.
|
||||
|
||||
Transient notifications will ignore this setting and timeout anyway.
|
||||
|
||||
=item B<font> (default: "Monospace 8")
|
||||
|
||||
Defines the font or font set used. Optionally set the size as a decimal number
|
||||
|
1
dunstrc
1
dunstrc
@ -80,6 +80,7 @@
|
||||
# Don't remove messages, if the user is idle (no mouse or keyboard input)
|
||||
# for longer than idle_threshold seconds.
|
||||
# Set to 0 to disable.
|
||||
# Transient notifications ignore this setting.
|
||||
idle_threshold = 120
|
||||
|
||||
### Text ###
|
||||
|
15
src/dbus.c
15
src/dbus.c
@ -138,6 +138,7 @@ static void on_notify(GDBusConnection * connection,
|
||||
/* hints */
|
||||
gint urgency = 1;
|
||||
gint progress = -1;
|
||||
gboolean transient = 0;
|
||||
gchar *fgcolor = NULL;
|
||||
gchar *bgcolor = NULL;
|
||||
gchar *category = NULL;
|
||||
@ -202,6 +203,19 @@ static void on_notify(GDBusConnection * connection,
|
||||
if (dict_value)
|
||||
raw_icon = get_raw_image_from_data_hint(dict_value);
|
||||
|
||||
/* Check for transient hints
|
||||
*
|
||||
* According to the spec, the transient hint should be boolean.
|
||||
* But notify-send does not support hints of type 'boolean'.
|
||||
* So let's check for int and boolean until notify-send is fixed.
|
||||
*/
|
||||
if((dict_value = g_variant_lookup_value(content, "transient", G_VARIANT_TYPE_BOOLEAN)))
|
||||
transient = g_variant_get_boolean(dict_value);
|
||||
else if((dict_value = g_variant_lookup_value(content, "transient", G_VARIANT_TYPE_UINT32)))
|
||||
transient = g_variant_get_uint32(dict_value) > 0;
|
||||
else if((dict_value = g_variant_lookup_value(content, "transient", G_VARIANT_TYPE_INT32)))
|
||||
transient = g_variant_get_int32(dict_value) > 0;
|
||||
|
||||
dict_value = g_variant_lookup_value(content, "value", G_VARIANT_TYPE_INT32);
|
||||
if (dict_value) {
|
||||
progress = g_variant_get_int32(dict_value);
|
||||
@ -246,6 +260,7 @@ static void on_notify(GDBusConnection * connection,
|
||||
n->urgency = urgency;
|
||||
n->category = category;
|
||||
n->dbus_client = g_strdup(sender);
|
||||
n->transient = transient;
|
||||
if (actions->count > 0) {
|
||||
n->actions = actions;
|
||||
} else {
|
||||
|
@ -62,7 +62,7 @@ void check_timeouts(void)
|
||||
notification *n = iter->data;
|
||||
|
||||
/* don't timeout when user is idle */
|
||||
if (x_is_idle()) {
|
||||
if (x_is_idle() && !n->transient) {
|
||||
n->start = time(NULL);
|
||||
continue;
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ void notification_print(notification * n)
|
||||
printf("\tcategory: %s\n", n->category);
|
||||
printf("\ttimeout: %d\n", n->timeout);
|
||||
printf("\turgency: %d\n", n->urgency);
|
||||
printf("\ttransient: %d\n", n->transient);
|
||||
printf("\tformatted: '%s'\n", n->msg);
|
||||
printf("\tfg: %s\n", n->color_strings[ColFG]);
|
||||
printf("\tbg: %s\n", n->color_strings[ColBG]);
|
||||
|
@ -53,6 +53,7 @@ typedef struct _notification {
|
||||
int displayed_height;
|
||||
const char *color_strings[3];
|
||||
bool first_render;
|
||||
bool transient;
|
||||
|
||||
int progress; /* percentage + 1, 0 to hide */
|
||||
int line_count;
|
||||
|
Loading…
x
Reference in New Issue
Block a user