emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: stardiviner <numbchild@gmail.com>
To: Maxim Nikulin <manikulin@gmail.com>
Cc: Org-mode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] make org-notify support for macOS desktop notification
Date: Mon, 5 Jul 2021 11:50:22 +0800	[thread overview]
Message-ID: <A6136E00-6503-4077-B89C-1A842E39D3FD@gmail.com> (raw)
In-Reply-To: <sbri31$pcr$1@ciao.gmane.io>

[-- Attachment #1: Type: text/plain, Size: 125 bytes --]

I updated the patch, I found the package `osx-lib` contains solution. So I removed the directly osascript process invocation.

[-- Attachment #2: 0001-org-clock.el-Make-org-notify-support-macOS-notificat.patch --]
[-- Type: application/octet-stream, Size: 1384 bytes --]

From 9bfb5d0d983f083558ecba51368ac4980f6008c7 Mon Sep 17 00:00:00 2001
From: stardiviner <numbchild@gmail.com>
Date: Sun, 4 Jul 2021 08:13:43 +0800
Subject: [PATCH] org-clock.el: Make org-notify support macOS notification

* lisp/org-clock.el (org-show-notification): Add support for macOS
notification.
---
 lisp/org-clock.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index cd930e875..314233156 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -859,7 +859,7 @@ use libnotify if available, or fall back on a message."
 	    org-show-notification-timeout
 	    nil
 	    (lambda () (w32-notification-close id)))))
-	((fboundp 'notifications-notify)
+	((and (eq system-type 'gnu/linux) (fboundp 'notifications-notify))
 	 (notifications-notify
 	  :title "Org mode message"
 	  :body notification
@@ -870,6 +870,8 @@ use libnotify if available, or fall back on a message."
 	((executable-find "notify-send")
 	 (start-process "emacs-timer-notification" nil
 			"notify-send" notification))
+        ((and (eq system-type 'darwin) (fboundp 'osx-lib-notify2))
+         (osx-lib-notify2 "Org mode message" notification))
 	;; Maybe the handler will send a message, so only use message as
 	;; a fall back option
 	(t (message "%s" notification))))
-- 
2.30.1 (Apple Git-130)


[-- Attachment #3: Type: text/plain, Size: 1720 bytes --]




> On Jul 4, 2021, at 1:48 PM, Maxim Nikulin <manikulin@gmail.com> wrote:
> 
> On 04/07/2021 07:23, stardiviner wrote:
>> I found `org-notify` does not support macOS desktop notification. So I write a small patch for this.
> 
> I am surprised that there is no OS-agnostic function in Emacs that sends simple notification, suitable when no advanced feature are necessary. Only OS-dependent variants are implemented for Linux and Windows.
> 
>> +                        (format "'display notification \"%s\" with title \"title\"'" notification "Org mode message")))
> 
> Unsafe substitution of the argument. There is no guarantee that notification has no quote characters. I do not know, which link you would prefer:
> - old https://xkcd.com/327/ "Robert'); DROP TABLE"
> - recent https://arstechnica.com/gadgets/2021/06/mass-data-wipe-in-my-book-devices-prompts-warning-from-western-digital/ Wipe data from NAS (accordingly to some sources, device can be protected by firewall, it is enough to open in a browser a page with a malicious <img src="..."> element, e.g. in a comment of an earlier visitor)
> 
> The preferred way is to pass such parameters as separate arguments of `start-process'. I am not familiar with osascript, I hope, it does not additionally interpret strings passed to "display notification" to do something fancy things. Example with sh:
> 
> Current unsafe variant:
> 
>>   sh -c "`printf 'echo "%s: %s - %s"' 'some-command' '"; echo another action ; echo "' 'second arg'
> With parameters passed as separate arguments to avoid interpretation of special characters:
> 
>>   sh -c 'echo "$0: $1 - $2"' 'some-command' '"; echo another action ; echo "' 'second arg'
> 
> 


  reply	other threads:[~2021-07-05  3:51 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-04  0:23 [PATCH] make org-notify support for macOS desktop notification stardiviner
2021-07-04  5:48 ` Maxim Nikulin
2021-07-05  3:50   ` stardiviner [this message]
2021-07-05 11:55     ` Maxim Nikulin
2021-07-05 22:36       ` stardiviner
2021-07-06  0:06         ` Tim Cross
2021-07-06  1:37           ` stardiviner
2021-07-06  8:12             ` Tim Cross
2021-07-06  1:45           ` [new patch] " stardiviner
2021-07-06  4:21             ` Christian Hopps
2021-07-06 15:30               ` [new patch] " stardiviner
2021-07-06 18:23                 ` Christian Hopps
2021-07-08  0:00                   ` stardiviner
2021-07-08  8:59                     ` Christian Hopps
2021-07-08  9:35                       ` STOP this patch for now stardiviner
2021-07-08 12:02                         ` Christian Hopps
2021-07-06 12:13             ` [PATCH] make org-notify support for macOS desktop notification Maxim Nikulin
2021-09-26  8:52             ` [new patch] " Bastien
2021-09-30 15:01               ` Max Nikulin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A6136E00-6503-4077-B89C-1A842E39D3FD@gmail.com \
    --to=numbchild@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=manikulin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).