Emacs Diary reminder using desktop notification
Published on May 03, 2019 by Sachin.
The post explains how to configure Emacs to alert diary reminders using Freedesktop notification protocol.
Figure 1: Emacs Diary desktop notification
Inspired by the post Use Emacs as a reminder, where the terminal-notifier is
used to send Emacs Diary reminder on MacOS, I decided to make use of
notification
extension which is builtin within Emacs to send Desktop
notifications via D-Bus.
Start by importing a notification
extension and create a placeholder for
session bus:
1: (require 'notifications) 2: 3: (defcustom appt-notification-bus :session 4: "D-Bus bus to use for notification." 5: :version "25.1" 6: :group 'appt-notification 7: :type '(choice (const :tag "Session bus" :session) string))
Once the session bus is in place, create a function to send a notification via
D-Bus using the notifications-notify
:
1: (defun psachin/appt-display (min-to-app new-time msg) 2: "Send notification." 3: (notifications-notify :bus appt-notification-bus 4: :title (format "Appointment in %s minutes." min-to-app) 5: :body (format "%s" msg) 6: :replaces-id nil 7: :app-icon nil 8: :timeout 5000 9: :desktop-entry "emacs"))
Finally call the function as a value to the variable appt-disp-window-function
(setq appt-disp-window-function (function psachin/appt-display))
Test the notification by creating an entry in Emacs diary, for ex:
Friday 20:10 to 20:30 Meeting with Rey
Refer the entire configuration here.