Emacs is able to send notifications on systems that support the
freedesktop.org Desktop Notifications Specification. In order to use
this functionality, Emacs must have been compiled with D-Bus support,
notifications library must be loaded.
This function sends a notification to the desktop via D-Bus, consisting of the parameters specified by the params arguments. These arguments should consist of alternating keyword and value pairs. The supported keywords and values are as follows:
- The notification title.
- The notification body text. Depending on the implementation of the notification server, the text could contain HTML markups, like ‘"<b>bold text</b>"’, hyperlinks, or images.
- The name of the application sending the notification. The default is
- The notification id that this notification replaces. id must be the result of a previous
- The file name of the notification icon. If set to
nil, no icon is displayed. The default is
:actions (key title key title
- A list of actions to be applied. key and title are both strings. The default action (usually invoked by clicking the notification) should have a key named ‘"default"’. The title can be anything, though implementations are free not to display it.
- The timeout time in milliseconds since the display of the notification at which the notification should automatically close. If -1, the notification's expiration time is dependent on the notification server's settings, and may vary for the type of notification. If 0, the notification never expires. Default value is -1.
- The urgency level. It can be
- When this keyword is given, the title string of the actions is interpreted as icon name.
- The type of notification this is, a string.
- This specifies the name of the desktop filename representing the calling program, like ‘"emacs"’.
:image-data (width height rowstride has-alpha bits channels data
- This is a raw data image format that describes the width, height, rowstride, whether there is an alpha channel, bits per sample, channels and image data, respectively.
- This is represented either as a URI (‘file://’ is the only URI schema supported right now) or a name in a freedesktop.org-compliant icon theme from ‘$XDG_DATA_DIRS/icons’.
- The path to a sound file to play when the notification pops up.
- A themable named sound from the freedesktop.org sound naming specification from ‘$XDG_DATA_DIRS/sounds’, to play when the notification pops up. Similar to the icon name, only for sounds. An example would be ‘"message-new-instant"’.
- Causes the server to suppress playing any sounds, if it has that ability.
- When set the server will not automatically remove the notification when an action has been invoked. The notification will remain resident in the server until it is explicitly removed by the user or by the sender. This hint is likely only useful when the server has the
- When set the server will treat the notification as transient and by-pass the server's persistence capability, if it should exist.
- Specifies the X, Y location on the screen that the notification should point to. Both arguments must be used together.
- Function to call when an action is invoked. The notification id and the key of the action are passed as arguments to the function.
- Function to call when the notification has been closed by timeout or by the user. The function receive the notification id and the closing reason as arguments:
expiredif the notification has expired
dismissedif the notification was dismissed by the user
close-notificationif the notification was closed by a call to
undefinedif the notification server hasn't provided a reason
Which parameters are accepted by the notification server can be checked via
This function returns a notification id, an integer, which can be used to manipulate the notification item with
:replaces-idargument of another
notifications-notifycall. For example:(defun my-on-action-function (id key) (message "Message %d, key \"%s\" pressed" id key)) ⇒ my-on-action-function (defun my-on-close-function (id reason) (message "Message %d, closed due to \"%s\"" id reason)) ⇒ my-on-close-function (notifications-notify :title "Title" :body "This is <b>important</b>." :actions '("Confirm" "I agree" "Refuse" "I disagree") :on-action 'my-on-action-function :on-close 'my-on-close-function) ⇒ 22 A message window opens on the desktop. Press "I agree" ⇒ Message 22, key "Confirm" pressed Message 22, closed due to "dismissed"
This function closes a notification with identifier id.
Returns the capabilities of the notification server, a list of strings. The following capabilities can be expected:
- The server will provide the specified actions to the user.
- Supports body text.
- The server supports hyperlinks in the notifications.
- The server supports images in the notifications.
- Supports markup in the body text.
- The server will render an animation of all the frames in a given image array.
- Supports display of exactly 1 frame of any given image array. This value is mutually exclusive with
- The server supports persistence of notifications.
- The server supports sounds on notifications.
Further vendor-specific caps start with