emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Sarah Bagby <bagby@geol.ucsb.edu>
To: emacs-orgmode@gnu.org
Subject: org-mode and appointment notifications on Mac OS 10.8
Date: Tue, 12 Feb 2013 23:16:54 -0800	[thread overview]
Message-ID: <EA76104A-9ACD-4141-8D33-2E4D810D9B5A@geol.ucsb.edu> (raw)

[-- Attachment #1: Type: text/plain, Size: 2613 bytes --]


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
bagby@geol.ucsb.edu
-----


[-- Attachment #2: Type: text/html, Size: 9654 bytes --]

             reply	other threads:[~2013-02-13  7:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-13  7:16 Sarah Bagby [this message]
2013-02-13 16:15 ` org-mode and appointment notifications on Mac OS 10.8 Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=EA76104A-9ACD-4141-8D33-2E4D810D9B5A@geol.ucsb.edu \
    --to=bagby@geol.ucsb.edu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).