forked from mirrors/org-mode
org-clock.el: Minor enhancements
* org-clock.el (org-clock-sound): Enhance docstring. (org-notify): Use the parameter `play-sound' as argument for `org-clock-play-sound'. (org-clock-play-sound): New optional argument `clock-sound' to override `org-clock-sound'.
This commit is contained in:
parent
13092befb6
commit
91a7e272b3
|
@ -189,17 +189,17 @@ All this depends on running `org-clock-persistence-insinuate' in .emacs"
|
||||||
:type 'boolean)
|
:type 'boolean)
|
||||||
|
|
||||||
(defcustom org-clock-sound nil
|
(defcustom org-clock-sound nil
|
||||||
"Sound that will used for notifications.
|
"Sound to use for notifications.
|
||||||
Possible values:
|
Possible values are:
|
||||||
|
|
||||||
nil no sound played.
|
nil No sound played
|
||||||
t standard Emacs beep
|
t Standard Emacs beep
|
||||||
file name play this sound file. If not possible, fall back to beep"
|
file name Play this sound file, fall back to beep"
|
||||||
:group 'org-clock
|
:group 'org-clock
|
||||||
:type '(choice
|
:type '(choice
|
||||||
(const :tag "No sound" nil)
|
(const :tag "No sound" nil)
|
||||||
(const :tag "Standard beep" t)
|
(const :tag "Standard beep" t)
|
||||||
(file :tag "Play sound file")))
|
(file :tag "Play sound file")))
|
||||||
|
|
||||||
(defcustom org-clock-modeline-total 'auto
|
(defcustom org-clock-modeline-total 'auto
|
||||||
"Default setting for the time included for the mode line clock.
|
"Default setting for the time included for the mode line clock.
|
||||||
|
@ -674,9 +674,10 @@ Notification is shown only once."
|
||||||
(setq org-clock-notification-was-shown nil)))))
|
(setq org-clock-notification-was-shown nil)))))
|
||||||
|
|
||||||
(defun org-notify (notification &optional play-sound)
|
(defun org-notify (notification &optional play-sound)
|
||||||
"Send a NOTIFICATION and maybe PLAY-SOUND."
|
"Send a NOTIFICATION and maybe PLAY-SOUND.
|
||||||
|
If PLAY-SOUND is non-nil, it overrides `org-clock-sound'."
|
||||||
(org-show-notification notification)
|
(org-show-notification notification)
|
||||||
(if play-sound (org-clock-play-sound)))
|
(if play-sound (org-clock-play-sound play-sound)))
|
||||||
|
|
||||||
(defun org-show-notification (notification)
|
(defun org-show-notification (notification)
|
||||||
"Show notification.
|
"Show notification.
|
||||||
|
@ -701,21 +702,23 @@ use libnotify if available, or fall back on a message."
|
||||||
;; a fall back option
|
;; a fall back option
|
||||||
(t (message "%s" notification))))
|
(t (message "%s" notification))))
|
||||||
|
|
||||||
(defun org-clock-play-sound ()
|
(defun org-clock-play-sound (&optional clock-sound)
|
||||||
"Play sound as configured by `org-clock-sound'.
|
"Play sound as configured by `org-clock-sound'.
|
||||||
Use alsa's aplay tool if available."
|
Use alsa's aplay tool if available.
|
||||||
(cond
|
If CLOCK-SOUND is non-nil, it overrides `org-clock-sound'."
|
||||||
((not org-clock-sound))
|
(let ((org-clock-sound (or clock-sound org-clock-sound)))
|
||||||
((eq org-clock-sound t) (beep t) (beep t))
|
(cond
|
||||||
((stringp org-clock-sound)
|
((not org-clock-sound))
|
||||||
(let ((file (expand-file-name org-clock-sound)))
|
((eq org-clock-sound t) (beep t) (beep t))
|
||||||
(if (file-exists-p file)
|
((stringp org-clock-sound)
|
||||||
(if (executable-find "aplay")
|
(let ((file (expand-file-name org-clock-sound)))
|
||||||
(start-process "org-clock-play-notification" nil
|
(if (file-exists-p file)
|
||||||
"aplay" file)
|
(if (executable-find "aplay")
|
||||||
(condition-case nil
|
(start-process "org-clock-play-notification" nil
|
||||||
(play-sound-file file)
|
"aplay" file)
|
||||||
(error (beep t) (beep t)))))))))
|
(condition-case nil
|
||||||
|
(play-sound-file file)
|
||||||
|
(error (beep t) (beep t))))))))))
|
||||||
|
|
||||||
(defvar org-clock-mode-line-entry nil
|
(defvar org-clock-mode-line-entry nil
|
||||||
"Information for the mode line about the running clock.")
|
"Information for the mode line about the running clock.")
|
||||||
|
|
Loading…
Reference in New Issue