summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2016-05-17 02:00:38 +0200
committerGravatar Tom Willemse2016-05-17 02:00:38 +0200
commit2260dde68d72536fd3502bcc20a55c1ea34dce89 (patch)
tree1d4c0bf7fce56666dff510ca57e1535d1621226a
parent62a267f633cc4de7ccfc372275eb33df1fc97ead (diff)
downloaddotfiles-2260dde68d72536fd3502bcc20a55c1ea34dce89.tar.gz
dotfiles-2260dde68d72536fd3502bcc20a55c1ea34dce89.zip
Show appointment notifications as notifications
-rw-r--r--emacs/.emacs.d/site-lisp/appt-init.el52
1 files changed, 42 insertions, 10 deletions
diff --git a/emacs/.emacs.d/site-lisp/appt-init.el b/emacs/.emacs.d/site-lisp/appt-init.el
index d24b68c..d516af2 100644
--- a/emacs/.emacs.d/site-lisp/appt-init.el
+++ b/emacs/.emacs.d/site-lisp/appt-init.el
@@ -26,20 +26,52 @@
;;; Code:
(require 'appt)
+(require 'notifications)
-(autoload 'jabber-send-message "jabber-chat")
-(defvar jabber-connections)
+(defun oni:appt-display-single-notification (min-to-appt cur-time body)
+ "Show an appointment in a desktop notification.
-(defun oni:appt-display-window-and-jabber (min-to-app new-time appt-msg)
- "Send a message to my phone jabber account."
- (let ((fmt "%s%s (in %s minutes)"))
- (jabber-send-message
- (car jabber-connections) "phone@ryuslash.org" nil
- (format fmt new-time appt-msg min-to-app) nil))
- (appt-disp-window min-to-app new-time appt-msg))
+MIN-TO-APPT should be a string with the number of minutes until
+the appointment. CUR-TIME is the current time. BODY is the text
+of the appointment."
+ (ignore cur-time)
+ (let ((minutes (string-to-number min-to-appt)))
+ (notifications-notify
+ :title (cond
+ ((= minutes 0) "Appointment right now")
+ ((= minutes 1) "Appointment in 1 minute")
+ (t (format "Appointment in %s minute(s)" min-to-appt)))
+ :body body)))
-(setq appt-display-diary nil)
+(defun oni:appt-display-multiple-notifications
+ (mins-to-appts cur-time bodies)
+ "Show multiple appointments in desktop notifications.
+MINS-TO-APPTS should be a list of strings with the numbers of
+minutes until the appointments. CUR-TIME is the current time.
+BODIES is the texts of the appointments."
+ (cl-mapc (lambda (min-to-appt body)
+ (oni:appt-display-single-notification
+ min-to-appt cur-time body))
+ mins-to-appts bodies))
+
+(defun oni:appt-display-notification (mins-to-appts cur-time bodies)
+ "Show one or more appointments in desktop notifications.
+
+MINS-TO-APPTS should be either a string with the number of
+minutes until the appointment, or a list of strings with the
+numbers of minutes until each appointment. CUR-TIME is the
+current time. BODIES is either a string with the text of the
+appointment or a list of strings with the text for each
+appointment."
+ (let ((func (if (listp bodies)
+ 'oni:appt-display-multiple-notifications
+ 'oni:appt-display-single-notification)))
+ (funcall func mins-to-appts cur-time bodies)))
+
+(setq appt-disp-window-function #'oni:appt-display-notification
+ appt-delete-window-function (lambda ())
+ appt-display-diary nil)
(provide 'appt-init)
;;; appt-init.el ends here