diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/jao-notify.el | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/sys/jao-notify.el b/sys/jao-notify.el index fdffe5e..dc48ca4 100644 --- a/sys/jao-notify.el +++ b/sys/jao-notify.el @@ -1,6 +1,6 @@ ;; jao-notify.el -- Interacting with notification daemon -;; Copyright (c) 2017, 2019 Jose Antonio Ortega Ruiz +;; Copyright (c) 2017, 2019, 2020 Jose Antonio Ortega Ruiz ;; Author: Jose Antonio Ortega Ruiz <jao@gnu.org> ;; Start date: Sun Jan 08, 2017 20:24 @@ -8,19 +8,25 @@ ;;; Comentary: -;; Simple notifications using notify-send +;; Simple notifications using echo or dbus notifications ;;; Code: -(defun jao-notify (msg &optional title icon) - (let* ((title (shell-quote-argument title)) - (msg (shell-quote-argument msg)) - (args (if title (format "%s %s" msg title) msg)) - (iflag (if (and (stringp icon) (file-exists-p icon)) - (format " -i %s" icon) - ""))) - (shell-command-to-string (format "notify-send %s%s" args iflag)))) +(defvar jao-notify-use-messages-p nil) +(defvar jao-notify-timeout 5000) + +(declare-function notifications-notify "notifications") +(defun jao-notify (msg &optional title icon) + (if jao-notify-use-messages-p + (message "%s%s%s" (or title "") (if title ": " "") (or msg "")) + (let* ((args `(:timeout ,jao-notify-timeout)) + (args (append args + (if title `(:title ,title :body ,msg) `(:title ,msg)))) + (args (if (and (stringp icon) (file-exists-p icon)) + (append args `(:app-icon ,(format "%s" icon))) + args))) + (apply 'notifications-notify args)))) (provide 'jao-notify) |