Show appointment notifications as notifications
This commit is contained in:
parent
62a267f633
commit
2260dde68d
1 changed files with 42 additions and 10 deletions
|
@ -26,20 +26,52 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(require 'appt)
|
(require 'appt)
|
||||||
|
(require 'notifications)
|
||||||
|
|
||||||
(autoload 'jabber-send-message "jabber-chat")
|
(defun oni:appt-display-single-notification (min-to-appt cur-time body)
|
||||||
(defvar jabber-connections)
|
"Show an appointment in a desktop notification.
|
||||||
|
|
||||||
(defun oni:appt-display-window-and-jabber (min-to-app new-time appt-msg)
|
MIN-TO-APPT should be a string with the number of minutes until
|
||||||
"Send a message to my phone jabber account."
|
the appointment. CUR-TIME is the current time. BODY is the text
|
||||||
(let ((fmt "%s%s (in %s minutes)"))
|
of the appointment."
|
||||||
(jabber-send-message
|
(ignore cur-time)
|
||||||
(car jabber-connections) "phone@ryuslash.org" nil
|
(let ((minutes (string-to-number min-to-appt)))
|
||||||
(format fmt new-time appt-msg min-to-app) nil))
|
(notifications-notify
|
||||||
(appt-disp-window min-to-app new-time appt-msg))
|
: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)
|
(provide 'appt-init)
|
||||||
;;; appt-init.el ends here
|
;;; appt-init.el ends here
|
||||||
|
|
Loading…
Reference in a new issue