[emacs-berlin] Showing org clock in window manager status bar
Sebastian Dümcke
code at sam-d.com
Sun May 10 10:42:38 UTC 2026
Dear list,
in our last meetup I had asked the question if anybody has some clever
ideas how to keep the currently running clock visible. My issue is that
when opening more than 1 frame that information in the mode line gets
covered by another frame and is not visible any more. Compacting the
mode line will not help if I open many more frames. I then came to the
realisation, that I could perhaps show this information in the status
bar of my window manager (I use sway with swaybar). The bar is never
overlapped by any windows and has enough "screen real-estate" left to
show this information.
The key ingredient is the emacs function ''org-clock-get-clock-string"
which provides exactly the string that will be shown in the mode line.
Assuming one starts an emacs server and adding some fail-safe code for
when org is not loaded or we are not clocked in, one arrives at the
following shell invocation:
emacsclient -e "(if (and (fboundp 'org-clocking-p) (org-clocking-p))
(substring-no-properties (org-clock-get-clock-string)) \"💤\")" | tr -d '"'
Aside: getting the original string out of a propertized string took me
the longest time! Somehow the manual focuses on extracting the
properties but never the string itself. I found
"substring-no-properties" by chance, if there is a better function to
use, please let me know.
How to get this string to show up in your bar is left as an exercise to
the reader. You can find my approach described here:
https://sam-d.com/blog/show-current-org-clock-and-task-in-sway-bar/
Hope this is useful you
Best
Sebastian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailb.org/pipermail/emacs-berlin/attachments/20260510/88d22cb0/attachment.htm>
More information about the emacs-berlin
mailing list