Hi,

I am using this since February 2024 and for me it is very useful (see attached script of just 17 lines).

The idea is to simplify two useful elements into one; when (org-clock-in) is executed, org-timer is triggered.

Maybe something like this should be an orgmode variable such as (setq org-clock-sync-timer t) to enable this feature.

Cheers,
pinmacs
;; seconds are probably lost, but gives more sync sensation
;;   org-clock-update-period is 60 by default
;;   and executes org-clock-update-mode-line
(defun my/sync-org-timer-with-clocked-time()
  ;; org-clock-get-clocked-time but in seconds
  (org-timer-start (+ (* 60 (or org-clock-total-time 0))
                      (org-time-convert-to-integer
                       (time-since org-clock-start-time)))))

(add-hook 'org-clock-in-hook 'my/sync-org-timer-with-clocked-time)
(add-hook 'org-clock-out-hook 'org-timer-stop)
;; Advise org-clock-update-time-maybe to also update the timer
(defun my/update-org-timer-with-clocked-time ()
  "Update the org timer to match the current clocked time, if a clock is active."
  (when (org-clock-is-active)
    (my/sync-org-timer-with-clocked-time)))
(advice-add 'org-clock-update-time-maybe :after #'my/update-org-timer-with-clocked-time)

Reply via email to