I'd like org-mode to reward me for completing a task by playing a nice sound when I change the state of a TODO
item to DONE
.
I tried two variations in my .emacs
file, neither one worked. I'm on Aquamacs on OSX.
Neither of these worked:
'(org-after-todo-state-change-hook (quote (org-clock-out-if-current) (play-sound-file "~/Library/Sounds/InkSoundStroke3.aif")))
'(org-after-todo-state-change-hook (quote (org-clock-out-if-current) (start-process-shell-command "afplay" nil "mplayer ~/Library/Sounds/InkSoundStroke3.aif")))
Edit: if you check the docstring for the hook (C-hv org-after-todo-state-change-hook
RET) you'll see that the new state is available in the variable org-state
, so we can test for that:
(add-hook 'org-after-todo-state-change-hook 'my-org-after-todo-state-change)
(defun my-org-after-todo-state-change ()
(when (string-equal org-state "DONE")
(org-clock-out-if-current)
(play-sound-file "~/Library/Sounds/InkSoundStroke3.aif")))