0

I would like to start the countdown function, (org-timer-set-timer) (C-c C-x ;), and trigger an action once the timer is over. Any hints on how this could be achieved? Shall I just use the run-at-time function instead? (This wouldn't show the countdown timer in the mode bar, but I guess I could survive).

2
  • 1
    org-timer-done-hook?
    – rpluim
    Sep 20, 2018 at 14:15
  • I know nothing about 'hooks', but thanks for the pointer, it looks like it is like a trigger which is what I think I need. Sep 21, 2018 at 13:23

2 Answers 2

4

'hooks' are variables to which you can add functions that will get automatically called, so that you don't need to go changing the original source code to get a behaviour change. This particular one is not documented, apart from its name. You can use it by doing eg:

(defun my-org-timer-hook ()
  (message "My timer done"))
(add-hook 'org-timer-done-hook 'my-org-timer-hook)

See (emacs) Hooks for a fuller explanation.

3
  • C-h v org-timer-done-hook says "Hook run after countdown timer reaches zero." so strictly speaking, it is documented. Do you mean "documented in the manual"?
    – NickD
    Sep 21, 2018 at 18:25
  • I somehow missed that, even though I was looking at org-timer.el. Documentation in the manual would be nice.
    – rpluim
    Sep 21, 2018 at 20:57
  • I doubt that it is going to be documented in the manual: it's a bit too generic, so the general emacs hook documentation that you linked to probably covers it.
    – NickD
    Sep 21, 2018 at 21:52
0

Thanks for this... I have extended your solution with an example of playing a sound file with afplay on MacOS when org-timer ends:

; play sound when org-timer completes
(add-hook 'org-timer-done-hook (lambda () (interactive)
                                 (shell-command "afplay $HOME/Downloads/ShipsBell.wav")))

Hope this proves useful for someone on the Internetz

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.