Native Human

Up

Brew tea with Emacs

Lately, I started drinking a lot of tea. When brewing tea it is very easy for me to miss the recommended steep time becaue I get distracted by other tasks. There are multiple tools out there, which reminds you when the tea is ready. Now I also found one which I can use within Emacs, the program which I am using most of the time. It can be found at github. However, it requires a bit of configuration which I want to show here. I prefer to get silent notices since I am working with other colleagues in the office and don't want to distract them. The easiest method to notify that the tea is ready is to just send out message. Unfortunately, such a message is easy to miss. Therfore, I can pop the *Messages* buffer up. Since I could be using another tool like firefox, I could still easily miss the message. Therefore looked for a method for bringing Emacs to the foreground and found the package wmctrl which also requires deferred. In addition to the emacs notification I also send a desktop-notification using notify-send. Alternatively, I could also use a dialog tool like zenity, but lately I prefer notify-send for this job. Then I bind the commands from the tea-time package to some "<menu> i" keys. Here is the code:

(load-file "~/.emacs.d/ext/emacs-deferred/deferred.el")
(load-file "~/.emacs.d/ext/emacs-wmctrl/wmctrl.el")
(load-file "~/.emacs.d/ext/tea-time/tea-time.el")

(require 'tea-time)

(defun tea-time-notification ()
  "Notify, when the tea is ready"
  (start-process "Tea is ready" "*Messages*" "notify-send" "critical" "tea is ready")
  (message "tea is ready")
  (pop-to-buffer "*Messages*")
  (wmctrl-raise-me)
  )

(setq tea-time-notification-hook 'tea-time-notification)

(define-prefix-command 'menu-keymap)
(global-set-key (kbd "<menu>") 'menu-keymap)

(progn
  (define-prefix-command 'tea-time-keymap)
  (global-set-key (kbd "<menu> i") tea-time-keymap)
  (define-key tea-time-keymap (kbd "t") 'tea-time)
  (define-key tea-time-keymap (kbd "s") 'tea-show-remaining-time)
  (define-key tea-time-keymap (kbd "c") 'tea-timer-cancel)
)
author:
mail:
comment:

Subscribe

List of posts