From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id OPX+BQy042BjUAAAgWs5BA (envelope-from ) for ; Tue, 06 Jul 2021 03:38:20 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id kD68AQy042BvfgAAbx9fmQ (envelope-from ) for ; Tue, 06 Jul 2021 01:38:20 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1F695220BF for ; Tue, 6 Jul 2021 03:38:19 +0200 (CEST) Received: from localhost ([::1]:59340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0a2T-0001em-0h for larch@yhetil.org; Mon, 05 Jul 2021 21:38:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0a26-0001dO-GF for emacs-orgmode@gnu.org; Mon, 05 Jul 2021 21:37:54 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:41541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0a24-000657-Lo for emacs-orgmode@gnu.org; Mon, 05 Jul 2021 21:37:54 -0400 Received: by mail-pj1-x102b.google.com with SMTP id oj10-20020a17090b4d8ab0290172f77377ebso84671pjb.0 for ; Mon, 05 Jul 2021 18:37:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=pgHDVwYXwp7tHZgLhjhTgsSADdLCkLdnwPDwOokCvvY=; b=VK/8jG54YfmaMjZHW5a0gVP6nwHsAk+kqn1ZnlCAJX5f04tGhfKWN5XJLRq1C/5d2v 5xVp6B1AE+C+BGWxUZwHFsxgWOXhFWz2D1RKFmwiODCsozEqFvv/KmJKLzpPhPfDUScs 55Ks2OmKLX8y9dyYAKEFHCK1FjlrpPOjR8t5W5zCdxReVvQKUS3/HOcDYYQEXfylcsqL QRpw38qh8uHv/FqOwRhfrrmt6fWK3fn86GZ8uDZqDQuu9kOM6dl/u4S79m3WkZCDB+cz Dfc5TGr4srj38jqkZUhgGnK9TEqeDcaeiKKTKO++VaZ8f/dyaeemmgwhBgPK3Bi6J11L BnMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=pgHDVwYXwp7tHZgLhjhTgsSADdLCkLdnwPDwOokCvvY=; b=oehpnQrCPnr2ToTyQHyeoYD4qNnYuEYWmsGH03K/0OxcbIlhwSHR0sIWVeooDR3PH2 fG3iNel3yxabBw80hPZsShSSAULMmdrvnxoLRUphy8OZquos2kc6TYkWCL4CeRNKnLN+ ukHuQUZP6vim/t7tXuhLWmtVw1CHdFgMbGPNeVGyimgSQrZzxAI/q3Y5ElIgYsWcnkf8 ox3etnBA8qzVFX67TfjDzHxdl09Phese2U3gT674f2kFGIoNPfOAhMLEneN43AIo4z5l rrcn58zrtoTYLR/70i+eniDhMV+6JSGV0xKmrUtpkT7TTsDhiR/d44Xcrt84tGuMqAbR LT9Q== X-Gm-Message-State: AOAM533+FwatEf9ZfU8um2sVH9dVqxoM4Cn8ZVxPk8oQjfIvikQB8LpG qKJxwU0DMnIrwQIskmKDew== X-Google-Smtp-Source: ABdhPJyx+Qx7rxM60g5D/6H19iJARLC9HUiy2XZin3Tj8Ktkv7LVK3pnqM6N18BBWGBckTZZgSjepw== X-Received: by 2002:a17:902:ed8b:b029:129:5259:95ca with SMTP id e11-20020a170902ed8bb0290129525995camr14737928plj.78.1625535470825; Mon, 05 Jul 2021 18:37:50 -0700 (PDT) Received: from smtpclient.apple ([150.109.103.155]) by smtp.gmail.com with ESMTPSA id r33sm16781237pgk.51.2021.07.05.18.37.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Jul 2021 18:37:50 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.100.0.2.22\)) Subject: Re: [PATCH] make org-notify support for macOS desktop notification From: stardiviner In-Reply-To: <87im1ol2lb.fsf@gmail.com> Date: Tue, 6 Jul 2021 09:37:46 +0800 Content-Transfer-Encoding: quoted-printable Message-Id: <1AD5C686-43DF-4233-AA98-1BA06826BD42@gmail.com> References: <5B57CD8B-AA91-4C63-A449-A07364083AEE@gmail.com> <87im1ol2lb.fsf@gmail.com> To: Tim Cross X-Mailer: Apple Mail (2.3654.100.0.2.22) Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=numbchild@gmail.com; helo=mail-pj1-x102b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Org-mode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1625535499; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=pgHDVwYXwp7tHZgLhjhTgsSADdLCkLdnwPDwOokCvvY=; b=SCN0Oru2bNcRHhDwKxq4hfYuTPmwu49zkaXlMeepOXkTU35II3qVZmXKwfPaXblhNXcQ64 zz92VUNhoG4HP6y1+vGqMfjSgZCWLkIIddhUPrMiNwbsADmrJvSe6PrCh1Z0k9EvAlXhCk 65v6UzppnKG+877kMGrNVD3jFtaQ8FX2jTowFlgUYe3yc0S8fia0rmUz46ailLq0t/6NYH NHAZjherKjs8pP1XIHxzyTcraEkL9H999aFOHprInhX5sbL5s/0b6DtKtvSfrKcMKyuraj GkWM9O6B+S9bIBE6HguRmmxekJY4JT7VOUP84b7NhX65koVTsmxSjUEXu/crmw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625535499; a=rsa-sha256; cv=none; b=Aaa99VUQdcYRjXx/73z/LJDs9Kz968/YKZGtrQTeBHjtJEpoM1spGenAtzRoIJuU82+Bgk T4Vg3+EGl6rAhzoKVnEomQWvyvzrnqzyGNRgefyGzwI30UGGvd9r3IHe2ZgoVV86Cq66UM MxnL6aS2rtZzywtms9zWcqchoedm3xamm/rEc3k0Ep8vwq3EKhrCE7/7DzpDqkX+WOgt8X s5Ys/GqFLvfyhtwAzXn9oxPgCJNsK1aDTOnrIyuMbHDUPSRHv07zIC6z2FN4YBLL0N26vD W9yZwbiFQUHMz7PnboHt1Js9yxHfv68t7SQlrQ9vQXHrYtbcvLcJUb0djHVW8w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b="VK/8jG54"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -2.61 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b="VK/8jG54"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 1F695220BF X-Spam-Score: -2.61 X-Migadu-Scanner: scn0.migadu.com X-TUID: nL4ICJDJ23Ny > On Jul 6, 2021, at 8:06 AM, Tim Cross wrote: >=20 >=20 > stardiviner writes: >=20 >>> On Jul 5, 2021, at 7:55 PM, Maxim Nikulin = wrote: >>>=20 >>> On 05/07/2021 10:50, stardiviner wrote: >>>> I updated the patch, I found the package `osx-lib` contains = solution. >>>> So I removed the directly osascript process invocation. >>>=20 >>> I have no objections any more. On the other hand I have no access to = macOS, so >>> I have not tested this patch. Feel free to ignore comments from this = message, >>> they are mostly matter of taste. >>>=20 >>> I expect that a simple script "notify-send" may allow to avoid = modification of >>> code. Something like (untested, unsure concerning "quoted form of = ...") >>>=20 >>> #!/usr/bin/env osascript >>> display notification (item 1 of argv) >>>=20 >>> However if osx-lib in is installed automatically, it may be more = convenient. >>> Unsure if some of currently supported linux distributions have = notify-send >>> that can not handle title as the first argument. >>>=20 >>>> - ((fboundp 'notifications-notify) >>>> + ((and (eq system-type 'gnu/linux) (fboundp = 'notifications-notify)) >>>=20 >>> Does it mean that `notifications-notify' is bound but it does not = work on >>> macOS? If so, maybe it is better to put new clause for 'darwin above = and to >>> drop 'gnu/linux here. =46rom my point of view, it is preferable to = avoid >>> additional requirement for `notifications-notify'. If someone will = create a >>> feature request for `notifications-notify' for macOS, it will just = work >>> without installing of additional packages as soon as such feature is >>> implemented. >>>=20 >>>=20 >> I indeed tried `notifications-notify`. And it does not work, reports = error that >> it needs dbus. PS. I used the Homebrew formulae version Emacs. >> I considered the order of conditions. Because notifications and = notify-send etc >> requires dbus. So I guess only Linux supports that. So add = system-type detection >> will be better. WDYT? >=20 > I think you can add dbus support to macOS using homebrew and that = might > resolve the issue. I checked my homebrew, I found the `dbus` is installed already. And in = Emacs `(featurep =E2=80=98dbus)` returns t. But `(org-show-notification =E2=80=9Ctest=E2=80=9D)` returns error: ``` Debugger entered--Lisp error: (dbus-error "No connection to bus" = :session) dbus-message-internal(1 :session "org.freedesktop.Notifications" = "/org/freedesktop/Notifications" "org.freedesktop.Notifications" = "Notify" dbus-call-method-handler :string "Emacs" :uint32 0 :string = "/opt/homebrew/Cellar/emacs-head@28/28.0.50_1/share..." :string "Org = mode message" :string "test" (:array) ((:dict-entry "urgency" (:variant = :byte 0))) :int32 3000) apply(dbus-message-internal 1 :session "org.freedesktop.Notifications" = "/org/freedesktop/Notifications" "org.freedesktop.Notifications" = "Notify" dbus-call-method-handler (:string "Emacs" :uint32 0 :string = "/opt/homebrew/Cellar/emacs-head@28/28.0.50_1/share..." :string "Org = mode message" :string "test" (:array) ((:dict-entry "urgency" (:variant = :byte 0))) :int32 3000)) dbus-call-method(:session "org.freedesktop.Notifications" = "/org/freedesktop/Notifications" "org.freedesktop.Notifications" = "Notify" :string "Emacs" :uint32 0 :string = "/opt/homebrew/Cellar/emacs-head@28/28.0.50_1/share..." :string "Org = mode message" :string "test" (:array) ((:dict-entry "urgency" (:variant = :byte 0))) :int32 3000) notifications-notify(:title "Org mode message" :body "test" :timeout = 3000 :urgency low) (cond ((functionp org-show-notification-handler) (funcall = org-show-notification-handler notification)) ((stringp = org-show-notification-handler) (start-process "emacs-timer-notification" = nil org-show-notification-handler notification)) ((fboundp = 'w32-notification-notify) (let ((id (w32-notification-notify :title "Org = mode message" :body notification :urgency 'low))) (run-with-timer = org-show-notification-timeout nil #'(lambda nil (w32-notification-close = id))))) ((fboundp 'notifications-notify) (notifications-notify :title = "Org mode message" :body notification :timeout (* = org-show-notification-timeout 1000) :urgency 'low)) ((executable-find = "notify-send") (start-process "emacs-timer-notification" nil = "notify-send" notification)) (t (message "%s" notification))) org-show-notification("test") eval((org-show-notification "test") nil) elisp--eval-last-sexp(nil) eval-last-sexp(nil) funcall-interactively(eval-last-sexp nil) call-interactively(eval-last-sexp nil nil) command-execute(eval-last-sexp) ``` Seems Emacs can=E2=80=99t connect to Homebrew dbus session. But I = checked homebrew services, the dbus service is running. Then I googled this problem. But have not found solution. Does anyone has experience to solve this problem? But lucky I found another way to invoke AppleScript notification way = built-in Emacs. #+begin_src emacs-lisp (ns-do-applescript "display notification \"hello world\"") (ns-do-applescript "display notification \"hello world\" with title = \"some title\"") #+end_src I will update the patch in next email. > At the very least, this will need to be investigated > because otherwise, adding this patch may break configurations for = users > who have added dbus support via homebrew and have notifications = working, > but have not installed the osx-lib package. >=20 > My only small concern with your proposed changes is that it will add a > dependency on a new package osx-lib, which I think is only available = in > melpa. At the very least, this will need to be documented somewhere. > However, I'm not sure what the situation is wrt adding code which > depends on an external package which is not available in either elpa = or > nongnuELPA? As org mode is a part of GNU Emacs, I suspect that any = code > which 'encourages' the use of melpa packages will not be acceptable.=20= >=20 > --=20 > Tim Cross >=20