From 86dce69d41d88fca806aeb0e77c5041c80b1ab60 Mon Sep 17 00:00:00 2001 From: stardiviner Date: Tue, 15 Feb 2022 00:02:16 +0800 Subject: [PATCH] Improve the ffmpeg-notification-default function under macOS. --- ffmpeg-utils.el | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/ffmpeg-utils.el b/ffmpeg-utils.el index 0cbb67c..86377ce 100644 --- a/ffmpeg-utils.el +++ b/ffmpeg-utils.el @@ -30,6 +30,7 @@ ;;; Code: (require 'notifications) +(require 'alert) (require 'transient) (defvar ffmpeg--output-filename nil @@ -45,22 +46,27 @@ "The default ffmpeg command process sentinel notification function." (setq mode-line-process nil) ; remove mode-line-process indicator. (let ((msg (format "ffmpeg cut %s finished" (file-name-nondirectory ffmpeg--output-filename)))) - (cond - ((and (eq system-type 'gnu/linux) (featurep 'dbus) (fboundp 'notifications-notify)) - (notifications-notify :title "Emacs ffmpeg-utils.el" :body msg)) - ((and (eq system-type 'darwin) (fboundp 'osx-lib-notify2)) - (require 'osx-lib) - (osx-lib-notify2 "Emacs ffmpeg-utils.el" msg)) - ((and (eq system-type 'darwin) (fboundp 'ns-do-applescript)) - (ns-do-applescript - (format "display notification \"%s\" with title \"%s\"" - msg "Emacs ffmpeg-utils.el"))) - ((and (eq system-type 'darwin) (executable-find "osascript")) - (start-process - "emacs-timer-notification" nil - "osascript" "-e" - (format "'display notification \"%s\" with title \"title\"'" msg "Emacs ffmpeg-utils.el"))) - (t (message (format "Emacs ffmpeg-utils.el: %s" msg)))))) + (pcase system-type + ('gnu/linux + (cond + ((and (featurep 'dbus) (fboundp 'notifications-notify)) + (notifications-notify :title "Emacs ffmpeg-utils.el" :body msg)))) + ('darwin + (cond + ((featurep 'alert) + (alert msg :title "Emacs ffmpeg-utils.el")) + ((and (featurep 'osx-lib) (bound-and-true-p osx-lib-start-terminal)) + (osx-lib-notify2 "Emacs ffmpeg-utils.el" msg)) + ((fboundp 'ns-do-applescript) + (ns-do-applescript + (format "display notification \"%s\" with title \"%s\"" + msg "Emacs ffmpeg-utils.el"))) + ((executable-find "osascript") + (start-process + "emacs-timer-notification" nil + "osascript" "-e" + (format "'display notification \"%s\" with title \"title\"'" msg "Emacs ffmpeg-utils.el"))))) + (t (message (format "Emacs ffmpeg-utils.el: %s" msg)))))) (defun ffmpeg--run-command (arglist) "Construct ffmpeg command with ARGLIST, SENTINEL-FUNC and BODY." -- 2.11.4.GIT