A neat trick that is often overlooked with emacs is that you can use emacs lisp out of the boundaries of the emacs frame. Especially for people running an emacs daemon, so as to not getting bothered with optimizing the initialization time of emacs, a simple:

emacsclient -e '(some-random-function)'

can get you quite far!

Recently I went back to using i3, a nice and simple manual tiling window manager. For having some info I use the default i3bar fed with info from the very nice i3blocks project. Below you can see a screenshot of this post being written:

i3-emacs.png

The thing is I'm quite a heavy org-clock user, as time always seems to elude me. To always have a look on the current clocked in item, as a way to force me work on it, I wanted a small block on the bar that indicates if I'm clocked in on anything and what. Jumping on the task by clicking is also possible!

The basic configuration to do this is pretty simple:

;; clocking Functions and i3-indicator
(use-package org-clock)

(defvar i3-clock-indicator-signal 7)

(defun i3-org-clock-indicator ()
  (if (org-clocking-p) ; check if org-clock is active
    (format "'%s' for %d min."
            org-clock-heading
            (org-clock-get-clocked-time))
    (format "🕶 chilling")))

(defun i3-org-clock-indicator-update ()
  (shell-command (format "pkill -SIGRTMIN+%d i3blocks"
                         i3-clock-indicator-signal)))

(add-hook 'org-clock-in-hook 'i3-org-clock-indicator-update)
(add-hook 'org-clock-out-hook 'i3-org-clock-indicator-update)

The all we have to do is create a block in our i3blocks.conf

[org-clock]
command=emacsclient -e '(i3-org-clock-indicator)' ; [[ -z "${BLOCK_BUTTON}" ]] || emacsclient -ce '(org-clock-goto)'
interval=60
signal=7
border=#cd5c5c

The things to watch out is to set the proper signal in both emacs and i3blocks and also put the prefered message. This is a small demonstration of how you can extend emacs to communicate better with its environment. Other well documented solutions include org-protocol to feed various data into org-mode from outside emacs and other wonderful ideas.

Hope you found this interesting! See you next time.