Skip to content

Instantly share code, notes, and snippets.

@bravosierrasierra
Created February 11, 2018 19:44
Show Gist options
  • Save bravosierrasierra/59d6d0c1ddff46a1b87b18738cecf8a2 to your computer and use it in GitHub Desktop.
Save bravosierrasierra/59d6d0c1ddff46a1b87b18738cecf8a2 to your computer and use it in GitHub Desktop.
** chronos
#+begin_src emacs-lisp
;;;; chronos plugin
(use-package chronos
:config
;; (use-package chronos)
;; https://github.com/dxknight/chronos
;; now is 17:00
;; 5 gives an expiry time of 17:05
;; 1:30 gives 18:30
;; 0:0:30 gives 30 seconds after 17:00
;; empty or 0 gives a count up timer starting now, at 17:00.
;; =17:00/Drink coffee + -5/Brew coffee + -5/Boil kettle + 25/Finish break
;; Which will give a timer at 5 o'clock to drink coffee, a timer five minutes before that (16:55) to
;; start brewing the coffee, a reminder five minutes before that (16:50) to put the kettle on and a
;; reminder 25 minutes after that (17:15) to finish drinking coffee and get back to work.
;; Key Action
;; a add a timer by specifying expiry time and a message
;; A add multiple consecutive timer(s) in one go
;; n/p move selection down/up (also C-n/C-p <down>/<up>)
;; SPC pause/unpause (pausing affects time to go and the expiry time, but not elapsed time)
;; d delete selected timer
;; D delete all expired timers
;; e edit selected timer
;; l lap selected timer
;; F freeze/unfreeze the display
;; q quit window
(defun bss/chronos-shell-notify (c)
"Notify expiration of timer C by running a shell command."
(if (eq system-type 'darwin)
(chronos--shell-command "Chronos shell notification for Mac OS X"
"/usr/local/bin/terminal-notifier"
(list "-sound" "default" "-title" "Сработал таймер" "-message" (chronos--message c))
)
(chronos--shell-command "Chronos shell notification for Linux & Windows"
"notify-send"
(list "-t" "3600000" "Сработал таймер" (chronos--message c))))
;; 24*60*60*1000 = 86400000 60*60*1000 = 3600000
)
(setq
;; chronos-shell-notify-program "mpg123"
;; chronos-shell-notify-parameters '("-q ~/.emacs.d/manual-addons/sounds/end.mp3")
;; chronos-shell-notify-program "notify-send"
;; chronos-shell-notify-parameters '("-t" "0" "Сработал таймер")
chronos-notification-wav "~/.emacs.d/manual-addons/sounds/end.wav"
chronos-expiry-functions '(chronos-buffer-notify
bss/chronos-shell-notify
;; chronos-sound-notify
chronos-message-notify
))
(use-package helm-chronos)
;; hack for manual addons. helm updates?
(setq helm-chronos--fallback-source
(helm-build-dummy-source "test"
:action '(("Add timer" . helm-chronos--parse-string-and-add-timer))))
(setq helm-chronos-standard-timers
'( " 10/Каша"
" 25/Каша"
" 4/Soak noodles"
" 25/Pomodoro: Work on helm-chronos + 5/Pomodoro: Rest"))
;; (global-set-key (kbd "C-x t") 'helm-chronos-add-timer)
(global-set-key (kbd "C-x t") '(lambda() (interactive)(helm-chronos-add-timer)(switch-to-buffer "*chronos*")))
;; (global-set-key (kbd "C-x t") 'chronos-add-timers-from-string)
(global-set-key (kbd "C-x C-t") '(lambda() (interactive)(switch-to-buffer "*chronos*")))
)
#+end_src
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment