Browse Source

org-clock.el: New option `org-show-notification-timeout'

* lisp/org-clock.el (org-show-notification-timeout): New option.
(org-show-notification): Use `w32-notification-notify' and the new
option.
Bastien 5 years ago
parent
commit
f9c34a7d51
2 changed files with 21 additions and 0 deletions
  1. 2 0
      etc/ORG-NEWS
  2. 19 0
      lisp/org-clock.el

+ 2 - 0
etc/ORG-NEWS

@@ -42,6 +42,8 @@ using ~display-buffer~. This allows users to control how source
 buffers are displayed by modifying ~display-buffer-alist~ or
 buffers are displayed by modifying ~display-buffer-alist~ or
 ~display-buffer-base-action~.
 ~display-buffer-base-action~.
 
 
+*** New option ~org-show-notification-timeout~
+
 ** New functions
 ** New functions
 *** ~org-columns-toggle-or-columns-quit~
 *** ~org-columns-toggle-or-columns-quit~
 =<C-c C-c>= bound to ~org-columns-toggle-or-columns-quit~ replaces the
 =<C-c C-c>= bound to ~org-columns-toggle-or-columns-quit~ replaces the

+ 19 - 0
lisp/org-clock.el

@@ -273,6 +273,15 @@ also using the face `org-mode-line-clock-overrun'."
 	  (const :tag "Just mark the time string" nil)
 	  (const :tag "Just mark the time string" nil)
 	  (string :tag "Text to prepend")))
 	  (string :tag "Text to prepend")))
 
 
+(defcustom org-show-notification-timeout 3
+  "Number of seconds to wait before closing Org notifications.
+This is applied to notifications send with `notifications-notify'
+and `w32-notification-notify' only, not other mechanisms possibly
+set throug `org-show-notification-handler'."
+  :group 'org-clock
+  :package-version '(Org . "9.4")
+  :type 'integer)
+
 (defcustom org-show-notification-handler nil
 (defcustom org-show-notification-handler nil
   "Function or program to send notification with.
   "Function or program to send notification with.
 The function or program will be called with the notification
 The function or program will be called with the notification
@@ -814,10 +823,20 @@ use libnotify if available, or fall back on a message."
 	((stringp org-show-notification-handler)
 	((stringp org-show-notification-handler)
 	 (start-process "emacs-timer-notification" nil
 	 (start-process "emacs-timer-notification" nil
 			org-show-notification-handler notification))
 			org-show-notification-handler notification))
+	((fboundp 'w32-notification-notify)
+	 (let ((id (w32-notification-notify
+		    :title "Org mode message"
+		    :body notification
+		    :urgency 'low)))
+	   (run-with-timer
+	    org-show-notification-timeout
+	    nil
+	    (lambda () (w32-notification-close id)))))
 	((fboundp 'notifications-notify)
 	((fboundp 'notifications-notify)
 	 (notifications-notify
 	 (notifications-notify
 	  :title "Org mode message"
 	  :title "Org mode message"
 	  :body notification
 	  :body notification
+	  :timeout (* org-show-notification-timeout 1000)
 	  ;; FIXME how to link to the Org icon?
 	  ;; FIXME how to link to the Org icon?
 	  ;; :app-icon "~/.emacs.d/icons/mail.png"
 	  ;; :app-icon "~/.emacs.d/icons/mail.png"
 	  :urgency 'low))
 	  :urgency 'low))