In bash syntax, one can use notify-send
to make a message appear in the desktop. How can we accomplish the same with elisp
?
Asked
Active
Viewed 655 times
1
2 Answers
6
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")

Michael Albinus
- 6,647
- 14
- 20
-
Thank you. It was really helpful. – BuddhiLW Dec 18 '21 at 18:04
1
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)

zzkt
- 456
- 3
- 10