In bash syntax, one can use notify-send
to make a message appear in the desktop. How can we accomplish the same with elisp
?
2 Answers
On GNU/Linux systems, there is the notifications.el package in core Emacs. Example from the info manual:
(require 'notifications)
(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"
The whole description is in the Elisp manual, see (info "(elisp) Desktop Notifications")
you can use notifications.el
as described in Michael Albinus' answer or the alert package from melpa which can be simpler in many cases and works cross-platform.
e.g. (alert "This is an alert" :title "My Alert" :category 'debug)