Displaying Org Mode Pomodoro Clock in the Menu Bar

As I’ve written in previous posts(1, 2), I’m a huge fan of Emacs Org mode. One thing that I’ve been doing on-and-off is to use Org mode to also track my time and implement the pomodoro method. It’s not entirely perfect, though one thing that has helped me a lot is to display the current pomodoro status in the menu bar, which makes it much easier to keep an eye on things even when I’m not using Emacs. No matter how great an OS Emacs is, surely you can’t live your whole life within it? ;)

The following screenshots show this in action under four different pomodoro clock types, respectively:

I’ll describe my setup in MacOS. The method should be replicable in Linux and Windows with minimum adaptations. I also came across a post for Linux and an app for Windows achieving something similar using alternative approaches, which you might be interested in checking out.

There are two key pieces to this approach:

The following is a step-by-step walkthrough:

  1. Specify the format you want the time to be displayed via org-pomodoro-time-format. In my case I have a simple format of mm:ss:
(setq-default org-pomodoro-time-format "%.2m:%.2s")
  1. Define a function that will produce the final output to be displayed on the menu bar for the script. In my case I made the following additions to the string output:
    • Prepend prefix characters “P”, “O”, “B”, “LB” to indicate the exact state of the pomodoro.
    • Display “N/A” when there’s no ongoing pomodoro.

    The entire function definition is as follows:

(defun jx/produce-pomodoro-string-for-menu-bar ()
  "Produce the string for the current pomodoro counter to display on the menu bar"
  (let ((prefix (cl-case org-pomodoro-state
            (:pomodoro "P")
            (:overtime "O")
            (:short-break "B")
            (:long-break "LB"))))
          (if (and (org-pomodoro-active-p) (> (length prefix) 0))
            (list prefix (org-pomodoro-format-seconds)) "N/A")))
  1. Install BitBar and ensure it runs normally. Open BitBar’s plugin folder. Create a shell script org-clock.1s.sh that calls emacsclient to evaluate the above-defined function:
    • The 1s part indicates that BitBar should evaluate this script every one second.
    • You may need to run chmod +x org-clock.1s.sh after creating it to make it executable.
    • If the emacsclient command fails, you may need to ensure that (server-start) is run automatically every time Emacs starts, so that the Emacs server/client is available.

    The script is as follows:

#!/bin/bash

export PATH='usr/local/bin:/usr/bin:$PATH'

# The default output of (org-pomodoro-format-seconds) contains parentheses, which I don't need. Sub them out with sed.
emacsclient --eval "(jx/produce-pomodoro-string-for-menu-bar)" | sed 's/["()]//g'

That’s it! Now, whenever you start a pomodoro in org-mode, you should be able to see the clock reflected in your menu bar :)