Skip to content

Instantly share code, notes, and snippets.

@ayman
Forked from justinhj/gist:eb2d354d06631076566f
Last active April 21, 2024 20:04
Show Gist options
  • Save ayman/bb72a25e16af9e6f30bf to your computer and use it in GitHub Desktop.
Save ayman/bb72a25e16af9e6f30bf to your computer and use it in GitHub Desktop.
Add native MacOS notifications to Emacs...simply.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Terminal notifier
;; requires 'sudo port install terminal-notifier'
;; stolen from erc-notifier
;;
;; (terminal-notifier-notify "Emacs notification"
;; "Something amusing happened")
(defvar terminal-notifier-command
(executable-find "terminal-notifier")
"The path to terminal-notifier.")
(defun terminal-notifier-notify (title message)
"Show a message with `terminal-notifier-command`."
(start-process "terminal-notifier"
"*terminal-notifier*"
terminal-notifier-command
"-title" title
"-message" message
"-activate" "org.gnu.Emacs"
"-sender" "org.gnu.Emacs"))
(defun timed-notification (time msg)
(interactive
"sNotification when (e.g: 2 minutes, 60 seconds, 3 days): \nsMessage: ")
(run-at-time time
nil
(lambda (msg) (terminal-notifier-notify "Emacs" msg))
msg))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment