Long compilations, long LLM training sessions, and other slow processes are facts of life for many software engineers. After more than a few seconds or minutes of waiting, it's natural to want to work on something else, or take a walk, or do anything else but stare at compilation output.
The ntfy
notification system is ideal for this purpose. It's open source (Github), it's simple to set up and use, and it can deliver notifications to
a web app, an Android app, or an iPhone app. You can host your own
server, or you can use the service at ntfy.sh, which includes both free and paid options. I host my own ntfy
server on render.com, but I sent the author, Philipp C. Heckel, a contribution through Github Sponsors.
The Emacs Lisp code below defines the command ntfy-compilation
. Running that command arranges for ntfy
to be run once the most recent compilation started by M-x compile
finishes. Even if you didn't call ntfy
in your compilation command, you can retroactively make sure that
you'll be notified.
(defvar ntfy-topic "YOUR-TOPIC") (defun ntfy-compilation-complete (buffer message) "Use <ntfy> to send an alert that compilation is complete." (let ((url-request-method "POST") (url-request-data (format "Compilation complete: %s" message))) (url-retrieve (format "https://YOUR-NTFY-SERVER-URL/%s" ntfy-topic) (lambda (status cbargs) 'ignore) nil t t))) (defun ntfy-compilation () "When compilation finishes, send an alert using <ntfy>." (interactive) (with-current-buffer "*compilation*" (make-local-variable 'compilation-finish-functions) (add-to-list 'compilation-finish-functions 'ntfy-compilation-complete)))
Thank you to Philipp for delivering one of the best kinds of notification: it's done.