Displaying Org Mode Pomodoro Clock in the Menu Bar
27 Dec 2020As 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:
- Normal pomodoro:
- Pomodoro in overtime (enabled with
org-pomodoro-manual-break
set tot
): - Short break
- Long break
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 function
org-pomodoro-format-seconds
, which outputs the pomodoro clock according toorg-pomodoro-time-format
(not necessarily in seconds, thus it’s somewhat of a misnomer). - the open-source app BitBar which evaluates an arbitrary command and displays the output in the menu bar.
The following is a step-by-step walkthrough:
- Specify the format you want the time to be displayed via
org-pomodoro-time-format
. In my case I have a simple format ofmm:ss
:
- 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:
- Install BitBar and ensure it runs normally. Open BitBar’s plugin folder. Create a shell script
org-clock.1s.sh
that callsemacsclient
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:
- The
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 :)