mirror of
https://github.com/SqrtMinusOne/pomm.el.git
synced 2025-12-10 14:43:03 +03:00
feat: minor mode for modeline, ETR -> ETA in transient
This commit is contained in:
parent
cf0e108b8d
commit
248ef58270
2 changed files with 29 additions and 21 deletions
11
README.org
11
README.org
|
|
@ -49,16 +49,7 @@ The package sends alerts via =alert.el=. The default style of alert is a plain =
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Modeline
|
** Modeline
|
||||||
If you want the timer to display in the modeline, add the following code to your config:
|
If you want the timer to display in the modeline, activate the =pomm-mode-line-mode= minor mode.
|
||||||
#+begin_src emacs-lisp
|
|
||||||
(add-to-list 'mode-line-misc-info '(:eval pomm-current-mode-line-string))
|
|
||||||
(add-hook 'pomm-on-tick-hook 'pomm-update-mode-line-string)
|
|
||||||
(add-hook 'pomm-on-tick-hook 'force-mode-line-update)
|
|
||||||
(add-hook 'pomm-on-status-changed-hook 'pomm-update-mode-line-string)
|
|
||||||
(add-hook 'pomm-on-status-changed-hook 'force-mode-line-update)
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
This is quite verbose, but as I don't use this feature, I want to avoid adding an unnecessary load to my Emacs.
|
|
||||||
|
|
||||||
** Polybar module
|
** Polybar module
|
||||||
If you want to display the Pomodoro status in something like polybar, you can add the following lines to your config:
|
If you want to display the Pomodoro status in something like polybar, you can add the following lines to your config:
|
||||||
|
|
|
||||||
39
pomm.el
39
pomm.el
|
|
@ -362,14 +362,30 @@ This sets the variable `pomm-current-mode-line-string' with a value
|
||||||
from `pomm-format-mode-line'. This is made so to minimize the load on
|
from `pomm-format-mode-line'. This is made so to minimize the load on
|
||||||
the modeline, because otherwise the updates may be quite frequent.
|
the modeline, because otherwise the updates may be quite frequent.
|
||||||
|
|
||||||
To add this to the modeline, add the following code to your config:
|
To add this to the modeline, activate the `pomm-mode-line-mode'
|
||||||
\(add-to-list 'mode-line-misc-info '\(:eval pomm-current-mode-line-string\)')
|
minor mode."
|
||||||
\(add-hook 'pomm-on-tick-hook 'pomm-update-mode-line-string\)
|
|
||||||
\(add-hook 'pomm-on-tick-hook 'force-mode-line-update\)
|
|
||||||
\(add-hook 'pomm-on-status-changed-hook 'pomm-update-mode-line-string\)
|
|
||||||
\(add-hook 'pomm-on-status-changed-hook 'force-mode-line-update)"
|
|
||||||
(setq pomm-current-mode-line-string (pomm-format-mode-line)))
|
(setq pomm-current-mode-line-string (pomm-format-mode-line)))
|
||||||
|
|
||||||
|
(define-minor-mode pomm-mode-line-mode
|
||||||
|
"Global minor mode for displaying the pomodoro timer status in the modeline."
|
||||||
|
:require 'pomm
|
||||||
|
:global t
|
||||||
|
:group 'pomm
|
||||||
|
:after-hook
|
||||||
|
(progn
|
||||||
|
(if pomm-mode-line-mode
|
||||||
|
(progn
|
||||||
|
(add-to-list 'mode-line-misc-info '(:eval pomm-current-mode-line-string))
|
||||||
|
(add-hook 'pomm-on-tick-hook #'pomm-update-mode-line-string)
|
||||||
|
(add-hook 'pomm-on-tick-hook #'force-mode-line-update)
|
||||||
|
(add-hook 'pomm-on-status-changed-hook #'pomm-update-mode-line-string)
|
||||||
|
(add-hook 'pomm-on-status-changed-hook #'force-mode-line-update))
|
||||||
|
(setq mode-line-misc-info (delete '(:eval pomm-current-mode-line-string) mode-line-misc-info))
|
||||||
|
(remove-hook 'pomm-on-tick-hook #'pomm-update-mode-line-string)
|
||||||
|
(remove-hook 'pomm-on-tick-hook #'force-mode-line-update)
|
||||||
|
(remove-hook 'pomm-on-status-changed-hook #'pomm-update-mode-line-string)
|
||||||
|
(remove-hook 'pomm-on-status-changed-hook #'force-mode-line-update))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun pomm-start ()
|
(defun pomm-start ()
|
||||||
"Start or continue the pomodoro timer.
|
"Start or continue the pomodoro timer.
|
||||||
|
|
@ -476,9 +492,10 @@ KIND is the same as in `pomm--state'"
|
||||||
(if (or (eq 'stopped status) (not (alist-get 'current pomm--state)))
|
(if (or (eq 'stopped status) (not (alist-get 'current pomm--state)))
|
||||||
"The timer is not running"
|
"The timer is not running"
|
||||||
(let* ((kind (alist-get 'kind (alist-get 'current pomm--state)))
|
(let* ((kind (alist-get 'kind (alist-get 'current pomm--state)))
|
||||||
|
(effective-start-time (alist-get 'effective-start-time (alist-get 'current pomm--state)))
|
||||||
(start-time (alist-get 'start-time (alist-get 'current pomm--state)))
|
(start-time (alist-get 'start-time (alist-get 'current pomm--state)))
|
||||||
(iteration (alist-get 'iteration (alist-get 'current pomm--state)))
|
(iteration (alist-get 'iteration (alist-get 'current pomm--state)))
|
||||||
(time-remaining (pomm--get-time-remaning)))
|
(kind-length (pomm--get-kind-length kind)))
|
||||||
(concat
|
(concat
|
||||||
(format "Iteration #%d. " iteration)
|
(format "Iteration #%d. " iteration)
|
||||||
"State: "
|
"State: "
|
||||||
|
|
@ -495,9 +512,10 @@ KIND is the same as in `pomm--state'"
|
||||||
(propertize
|
(propertize
|
||||||
(format-time-string "%H:%M:%S" (seconds-to-time start-time))
|
(format-time-string "%H:%M:%S" (seconds-to-time start-time))
|
||||||
'face 'success)
|
'face 'success)
|
||||||
". Time remaining: "
|
". Estimated end time: "
|
||||||
(propertize
|
(propertize
|
||||||
(format-seconds "%.2h:%.2m:%.2s" time-remaining)
|
(format-time-string "%H:%M:%S"
|
||||||
|
(seconds-to-time (+ effective-start-time kind-length)))
|
||||||
'face 'success))))))
|
'face 'success))))))
|
||||||
|
|
||||||
(defclass pomm--transient-history (transient-suffix)
|
(defclass pomm--transient-history (transient-suffix)
|
||||||
|
|
@ -520,8 +538,7 @@ The class doesn't actually have any value, but this is necessary for transient."
|
||||||
(let ((kind (alist-get 'kind item))
|
(let ((kind (alist-get 'kind item))
|
||||||
(iteration (alist-get 'iteration item))
|
(iteration (alist-get 'iteration item))
|
||||||
(start-time (alist-get 'start-time item))
|
(start-time (alist-get 'start-time item))
|
||||||
(end-time (alist-get 'end-time item))
|
(end-time (alist-get 'end-time item)))
|
||||||
(paused-time (alist-get 'paused-time item)))
|
|
||||||
(concat
|
(concat
|
||||||
(if (< iteration previous-iteration)
|
(if (< iteration previous-iteration)
|
||||||
(let ((is-first (= previous-iteration 1000)))
|
(let ((is-first (= previous-iteration 1000)))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue