In a previous article, I showcased a script I made to display org-pomodoro’s
current status to polybar. Since then my workflow has evolved and I have added
some functionalities to this script.
First, org-pomodoro itself has evolved. There’s a new option to keep the pomodoro
going when it ends, going into overtime and requiring a manual break. I like it
because 25 minutes can sometimes be too short and not wanting to break my focus
on the current task I would end up ignoring it for a few minutes making the
break timer incorrect. You can turn on this option with :
I also modified my script to allow me to control org-pomodoro through clicks on
the polybar modules. The new actions are :
- Ending a pomodoro. The new option requires the user to end the pomodoro
manually. I simply can do so by double-clicking on the polybar module instead
of calling org-pomodoro from an emacsclient instance.
- Restart a pomodoro. Allows me to go back to work on the same task as before
after or during a break.
- Kill a pomodoro. If I have an emergency or am disturbed during a pomodoro, I
can quickly kill it with a middle mouse click on the module.
- Add a new to-do to my inbox. Right clicking the modules open a floating window
with an org-capture. If a pomodoro is running it selects my simple to-do
template. If no pomodoro is running however it uses another template designed
to directly start a pomodoro from the newly created task upon capture.
Altogether it provides me with a convenient interface to org-pomodoro even when
outside Emacs.
You’ll find all the code necessary here but I’ll go over the installation process.
To set this up you’ll need to copy the org-pomodoro.sh script.
I use doom-emacs and rely on one of it’s functions to create a pop-up window
with the wanted capture template. I have however provided in the script an
alternative for non doom users that relies on org-protocol so you’ll need to set
that up properly if needed. To use simply change to false DOOM_EMACS
variable at the top of the script.
Then you’ll need to configure polybar to use the pomicons font and you’ll need
to create a module to call the script. The argument of the call determines
the action so you can bind them to any type of click or wheel-scroll.
Available arguments are :
- No argument to display the pomodoro
toggle
to toggle between the different display modes
end-or-restart
to end current pomodoro or restart last one depending on
context
kill
to kill the current pomodoro
new
to create a to-do and start pomodoro from said to-do if none is active
You can find my module configuration in the gist.
For new
to work properly you’ll need two org-capture templates. Your usual
to-do template and another template marked with the :pomodoro t
property.
So for example :
And now we have to make this :pomodoro t
property actually do something. To do
so I wrote a function that will be run at the end of a capture through a hook :
What this does is check that the capture was not aborted and that the templates
has the :pomodoro t
property and if it does it will reset the pomodoro count
if necessary, go to the new headline, start the clock and finally start the pomodoro.
For the end-or-restart
command I wrote a function that basically behaves the
same as org-pomodoro
except there is no prompt, to avoid the command getting
stuck on it and it uses org-clock-in-last meaning it automatically uses the last
clocked item instead of requiring to be on a headline or having another prompt.
So we also need to add it to our config :
This is called from the script so if you change it’s name don’t forget to modify
it in the script.
That’s it for the emacs side of things. All that’s left is to configure the
script org-pomodoro.sh
through the variables at the top of the file.
Finally if you use a tiling window manager capable of this, it’s probably a good
idea to set the windows created by the script as floating. They are named
“org-capture”. Here’s how to do it in i3 :