From c50195261deefe5811effede7811ba62c604461a Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Wed, 12 Apr 2017 08:24:19 +0200 Subject: [PATCH] Setup alert.el based on the terminal type If running under Termux, use the `termux` alert style; otherwise, use `notifications`. --- init.el | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index cd5860b..c32b940 100644 --- a/init.el +++ b/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