From 5347d17e1e728430d1f8cd970dcd54aaf71c85bf Mon Sep 17 00:00:00 2001 From: jao Date: Wed, 18 Nov 2020 23:40:56 +0000 Subject: make jao-notify aware we now use ednc --- sys/jao-notify.el | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'sys') 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 ;; 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) -- cgit v1.2.3