Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Sarah Bagby <bagby <at> geol.ucsb.edu>
Subject: org-mode and appointment notifications on Mac OS 10.8
Newsgroups: gmane.emacs.orgmode
Date: Wednesday 13th February 2013 07:16:54 UTC (over 3 years ago)
I've been looking for a way to get org-mode to push appointment
notifications from my org-agenda to the Notification Center on Mac OS 10.8
(Mountain Lion).  Thanks to Eloy DurĂ¡n's terminal-notifier project (https://github.com/alloy/terminal-notifier),
the code below seems to do the trick.  This is mostly hacked together from
other people's approaches using different window functions:

http://emacs-fu.blogspot.com/2009/11/showing-pop-ups.html
http://article.gmane.org/gmane.emacs.orgmode/5271
http://article.gmane.org/gmane.emacs.orgmode/5806

I'm posting in the hopes that this will be useful to others, and would
welcome any feedback.

Sarah Bagby

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(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_1.4.2/terminal-notifier.app/Contents/MacOS/terminal-notifier")
 
(defun my-appt-send-notification (title msg)
  (shell-command (concat my-notifier-path " -message " msg " -title "
title)))

;; 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))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


-----
Sarah Bagby
Postdoctoral scientist, Valentine lab
Department of Earth Science / Marine Science Institute
Webb Hall
UC Santa Barbara
Santa Barbara, CA 93106
[email protected]
-----
 
CD: 4ms