-
Notifications
You must be signed in to change notification settings - Fork 351
Guides
When you send a notification using notify-send
or dunstify
this information
is sent to dunst over D-Bus. This information can be really useful in debugging
dunst.
To have a look at what is send to dunst over D-Bus, take a look at the output of
the command
dbus-monitor path=/org/freedesktop/Notifications
This will tell you every time a notification is sent what the contents are of that notification and when it is closed again. The D-Bus is really easy to integrate with your program, so you could create an application that does something every time a dunst notification is closed.
With PR 775 merged, dunst has the ability to draw a progress bar under the notification. This is very useful for brightness or volume notifications. This guide will explain how to use and customize that progress bar.
First check if your dunst version is recent enough. The current git master or everything after 1.6.0 should be good.
To test if you can see a progress bar, use this command:
dunstify "Progress: " -h int:value:60
This should look something like this
You can change the 60 for any value you like. To make useful volume notifications you need a bit more, though. Firstly , the value should be changing with the volume. Secondly, if you change your volume a few times in a row, you don't want to have multiple notifications. They should replace each other.
To address the first thing, you can simply replace the progress value with a command.
dunstify "Progress: " -h int:value:"`ponymix get-volume`"
You can replace ponymix with any volume command that outputs a single value.
Replacing notifications is also very easy. Think of a name for you group of notifications, like "audio", and use the following command
dunstify -h string:x-canonical-private-synchronous:audio "Volume: " -h int:value:"`ponymix get-volume`"
This passes a string named x-cannonical-private-synchronous
with the value audio
to dunst. You can name the string x-dunst-stack-tag
as well if you find it easier.
After making such nice use of the progress bar, you might want to change how it looks.
The settings you want to look at are highlight
, progress_bar
, progress_bar_height
, progress_bar_min_width
, progress_bar_max_width
and progress_bar_frame_width
.
Most of these settings are self-explanatory, but I'll explain a few of them.
The highlight
setting changes the colour of the progress bar (and in the future maybe
other similar things). It can be specified per urgency or per notification, not in the
[global] section.
The progress_bar
setting determines if a progress bar is drawn. Make sure it's set to
true if you want to use it (this is the default).
If you've configured it, it might look something like this
A progress bar is drawn for every urgency
If you like it, the config for this can be found here.
The above command is very useful, and you could change your window manager config to run this command every time you hit a hotkey to change your volume. A similar thing could be done for brightness changes.
You might run into some trouble, however when the change in volume or brightness is not yet available to the brightness command. To look at a completely working example you could use, look at the progress-notify.sh script from the contrib directory.
Dunst has support for notification actions, which allow you to immediately react upon receiving a notification without first opening the app. You can for example mark a message as read, or click to view the rest of the email. After a notification is closed, however, the action is also invalidated. In other words, you can't activate the action of a notifications that is pulled from your history.
You can send a notification with an action using dunstify:
dunstify -A yes,ACCEPT -A no,DECLINE "Call waiting"
The first word after -A
is the name of the action and the string after the comma is the description.
There are a two ways you can activate an action:
To open the context menu, first add the following to your dunstrc:
[global]
mouse_middle_click = context,close_current #close_current is optional
After saving that and restarting dunst you can activate the action by middle clicking on it. This will open dmenu (or the dmenu alternative you've configured in your dunstrc) with the different actions you can activate. If you've used the dunstify command from above, you'll see the action you've chosen printed in stdout.
Add the following to your dunstrc:
[global]
mouse_middle_click = do_action,close_current #close_current is optional
[all_notifications] # A rule that matches all notifications
action_name = "no" # Optional, to activate the action "no" automatically
If you now middle click on a notification the action is activated directly, if available. Otherwise a context menu is opened as well.