Skip to content

Instantly share code, notes, and snippets.

@danielsz
Last active May 7, 2022 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save danielsz/ac19353e718dde3dea72 to your computer and use it in GitHub Desktop.
Save danielsz/ac19353e718dde3dea72 to your computer and use it in GitHub Desktop.
(defvar notify-command (executable-find "terminal-notifier") "The path to terminal-notifier")
(defun notify (title message)
"Shows a message through the Notification center system using
`notify-command` as the program."
(flet ((encfn (s) (encode-coding-string s (keyboard-coding-system))) )
(let* ((process (start-process "notify" nil
notify-command
"-title" (encfn title)
"-message" (encfn message))))))
t)
(defun my-erc-hook (match-type nick message)
"Shows a growl notification, when user's nick was mentioned. If the buffer is currently not visible, makes it sticky."
(unless (posix-string-match "^\\** *Users on #" message)
(notify
(concat "ERC: name mentioned on: " (buffer-name (current-buffer)))
message
)))
(when (bound-and-true-p notify-command)
(add-hook 'erc-text-matched-hook 'my-erc-hook))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment