Setup alert.el based on the terminal type
If running under Termux, use the `termux` alert style; otherwise, use `notifications`.
This commit is contained in:
parent
b3c87b5d9a
commit
c50195261d
32
init.el
32
init.el
@ -792,7 +792,37 @@
|
||||
(use-package alert
|
||||
:ensure t
|
||||
:config
|
||||
(setq alert-default-style 'notifications))
|
||||
(setq alert-default-style
|
||||
(if (termux-p)
|
||||
(progn
|
||||
;; TODO Remove this as soon as my PR gets merged
|
||||
;; https://github.com/jwiegley/alert/pull/41
|
||||
(unless (fboundp 'alert-termux-notify)
|
||||
(defcustom alert-termux-command (executable-find "termux-notification")
|
||||
"Path to the termux-notification command.
|
||||
This is found in the termux-api package, and it requires the Termux
|
||||
API addon app to be installed."
|
||||
:type 'file
|
||||
:group 'alert)
|
||||
|
||||
(defun alert-termux-notify (info)
|
||||
"Send INFO using termux-notification.
|
||||
Handles :TITLE and :MESSAGE keywords from the
|
||||
INFO plist."
|
||||
(if alert-termux-command
|
||||
(let ((args (nconc
|
||||
(when (plist-get info :title)
|
||||
(list "-t" (alert-encode-string (plist-get info :title))))
|
||||
(list "-c" (alert-encode-string (plist-get info :message))))))
|
||||
(apply #'call-process alert-termux-command nil
|
||||
(list (get-buffer-create " *termux-notification output*") t)
|
||||
nil args))
|
||||
(alert-message-notify info)))
|
||||
|
||||
(alert-define-style 'termux :title "Notify using termux"
|
||||
:notifier #'alert-termux-notify))
|
||||
'termux)
|
||||
'notifications)))
|
||||
|
||||
(use-package newsticker
|
||||
:demand
|
||||
|
Loading…
Reference in New Issue
Block a user