-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnotifications.conf.el
34 lines (31 loc) · 1.43 KB
/
notifications.conf.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(when (string-equal system-type "darwin")
(defun jd:xml-unescape-string (string)
(with-temp-buffer
(insert string)
(dolist (substitution '(("&" . "&")
("<" . "<")
(">". ">")
("'" . "'")
(""" . "\"")))
(goto-char (point-min))
(while (search-forward (car substitution) nil t)
(replace-match (cdr substitution) t t nil)))
(buffer-string)))
(require 's)
(defun jd:escape-term-chars (string)
(s-replace-all '(("[" . "\\\\[")) string))
(defun notifications-notify (&rest params)
(let ((title (plist-get params :title))
(body (plist-get params :body)))
(call-process "terminal-notifier" nil nil nil
"terminal-notifier"
"-contentImage" (or (plist-get params :image-path) "")
"-appIcon" (or (plist-get params :app-icon) "")
"-message" (if body
(jd:escape-term-chars (jd:xml-unescape-string body))
"")
"-title" (if title
(jd:escape-term-chars (jd:xml-unescape-string title))
"")
;; "-activate" "org.gnu.Emacs" ; starting with 1.8.0 this blocks?!
"-sender" "org.gnu.Emacs"))))