Skip to content

Instantly share code, notes, and snippets.

@squiter
Last active March 21, 2021 13:30
Show Gist options
  • Save squiter/4475c96365575b7237c4 to your computer and use it in GitHub Desktop.
Save squiter/4475c96365575b7237c4 to your computer and use it in GitHub Desktop.
Adding desktop notifications to your org-mode

This script is for OSX only! ;)

First install terminal-notifier app:

brew install terminal-notifier

After that, using this awesome scritp with some customizations in your .emacs.

(require 'appt)
(setq appt-time-msg-list nil)    ;; clear existing appt list
(setq appt-display-interval '10) ;; warn every 10 minutes from t - appt-message-warning-time
(setq
  appt-message-warning-time '10  ;; send first warning 10 minutes before appointment
  appt-display-mode-line nil     ;; don't show in the modeline
  appt-display-format 'window)   ;; pass warnings to the designated window function
(appt-activate 1)                ;; activate appointment notification
(display-time)                   ;; activate time display

(org-agenda-to-appt)             ;; generate the appt list from org agenda files on emacs launch
(run-at-time "24:01" 3600 'org-agenda-to-appt)           ;; update appt list hourly
(add-hook 'org-finalize-agenda-hook 'org-agenda-to-appt) ;; update appt list on agenda view

;; set up the call to terminal-notifier
(defvar my-notifier-path "terminal-notifier")  
(defun my-appt-send-notification (title msg)
  (shell-command 
    (concat my-notifier-path " -message " msg " -title " title " -sender org.gnu.Emacs -active org.gnu.Emacs)))

;; designate the window function for my-appt-send-notification
(defun my-appt-display (min-to-app new-time msg)
  (my-appt-send-notification 
    (format "'Appointment in %s minutes'" min-to-app)    ;; passed to -title in terminal-notifier call
    (format "'%s'" msg)))                                ;; passed to -message in terminal-notifier call
(setq appt-disp-window-function (function my-appt-display))

And that's all folks!

@rranelli
Copy link

Ok, I have to do this....

meme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment