From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id YCW4DVUS5GAO7QAAgWs5BA (envelope-from ) for ; Tue, 06 Jul 2021 10:20:37 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id SBxqCVUS5GBCQgAAB5/wlQ (envelope-from ) for ; Tue, 06 Jul 2021 08:20:37 +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 EDC8326055 for ; Tue, 6 Jul 2021 10:20:35 +0200 (CEST) Received: from localhost ([::1]:58512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0gJm-0006oC-8T for larch@yhetil.org; Tue, 06 Jul 2021 04:20:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0gIh-0006lH-AD for emacs-orgmode@gnu.org; Tue, 06 Jul 2021 04:19:27 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:39881) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0gIf-0004HH-9F for emacs-orgmode@gnu.org; Tue, 06 Jul 2021 04:19:27 -0400 Received: by mail-pg1-x52f.google.com with SMTP id a2so20681053pgi.6 for ; Tue, 06 Jul 2021 01:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:date:in-reply-to :message-id:mime-version:content-transfer-encoding; bh=8xoCTMQZ1fy8ALDA7CT3v7bGfBovWBKyZztpr8piTDQ=; b=qM70SCrsWw0hBxwt9VBpms059AY1eptF/8x4HYRzEhu+7Igj+atDmBlK4XffyOZcgS A2Lnc9djWvGf94blgzasrnkK+LXgHl5UrI272nsuxeLFOg3tf6dakQNu0BUDDLstCgPo fC/e5pQb4tCgixF38HW6ic+T2WMnrfWnWn5rvyee8QPEoRL3ANKEwe22h65g1OiWCMw3 FimBEnzgSdLL72t5qMbjIbHn/72J/CE1nAeqZx8vIRIh2HMgS6sOVJqTut7dtPGMefXv L4i7zkwGuXhkiFmwVkTL3fheyqthvUsrevW9FtrXr9aw4yWygNNZYxKJptbPlqDC5Mb9 5FLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject:date :in-reply-to:message-id:mime-version:content-transfer-encoding; bh=8xoCTMQZ1fy8ALDA7CT3v7bGfBovWBKyZztpr8piTDQ=; b=KxfjtoFSZPu1brR1ZdCeW0tLZ6Itbjxm/c0wS2y4XIpNCHmYxgfL/9NArI0eUDv+Xo PDYfDdJ7JuZVq8RiBCppto5OlhCgiB0hZ3lhjru6sT63TS8jQ/PGdTpZunIWK9Tenr8r MvwUc5/27rm7AjIecaIqoV5EFa6DSBFXuvJBK2eVB0aDO/u4d0SotiYTQlurU47N3GZ8 U9W+/n7EjmWqAw2ypLYzXGDnSksm0mLZHAoi+EfXXdh3hVyC+OHHW+k9AnN7eLyokl30 f0U541tvgOuifE7FOf8E/op7SyMB7Xv+P/qTVuISKdOKiNwnOuCLbUXNGM0sfzSKaKzg J8pA== X-Gm-Message-State: AOAM533qYZFKOcyxv18/AtvrmSg3k5jOGCOKAulfSUcVYRcgCew7+/Bp 2o/az4Vyw4Oa/ZDsIO1UTEHvbFd9U0Q= X-Google-Smtp-Source: ABdhPJzBXNltQR5WobUK2jjcTnP/XM03uqZl6w+5freKdh0toyHfBkUFvKGrIfMfivhQUQ1UimwISg== X-Received: by 2002:a05:6a00:2162:b029:308:9346:2f55 with SMTP id r2-20020a056a002162b029030893462f55mr19117374pff.49.1625559563359; Tue, 06 Jul 2021 01:19:23 -0700 (PDT) Received: from tim-desktop (220-235-1-69.dyn.iinet.net.au. [220.235.1.69]) by smtp.gmail.com with ESMTPSA id h10sm15693557pfh.33.2021.07.06.01.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 01:19:22 -0700 (PDT) References: <5B57CD8B-AA91-4C63-A449-A07364083AEE@gmail.com> <87im1ol2lb.fsf@gmail.com> <1AD5C686-43DF-4233-AA98-1BA06826BD42@gmail.com> User-agent: mu4e 1.5.13; emacs 28.0.50 From: Tim Cross To: stardiviner Subject: Re: [PATCH] make org-notify support for macOS desktop notification Date: Tue, 06 Jul 2021 18:12:18 +1000 In-reply-to: <1AD5C686-43DF-4233-AA98-1BA06826BD42@gmail.com> Message-ID: <87eecbn9bs.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=theophilusx@gmail.com; helo=mail-pg1-x52f.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=1625559636; 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=8xoCTMQZ1fy8ALDA7CT3v7bGfBovWBKyZztpr8piTDQ=; b=MrE5LPBEKPABfxMvw+r9A3VkX8VCmQv5hNjRdWXptaBHQZxEz2txYjzpFmHAF2SMekcoyV yVq4F1c7JiSCHCIUSWWg7sTY0DvsN7i/9AbTWQ5ys5frPvE+HAryaDtYy6mJ/8gQO0QNx4 gCVj48eXnCWhLL6sIJXrTpPqVievjmNiK6+OTXEVw7B15THG8iRIuSUcj6ZgSmD7Mv6s1d muj0zzPH/huKiW8Gmnmo6Zk9GiezCz/fxMK/92gMtTeb73VzUathbn2ArGvH5GsnIpB889 dxaDJ6QX7Q3ZXVDfxD/XmjfxrBl2sJD6MkkruobzlRAthNrV8kgXvC2EyRRZvA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625559636; a=rsa-sha256; cv=none; b=QKCIecIVI+DviLE5a18qMYo+qI/abWd0j1gm8fEZffws81BttpONf0opWnSvWxfrr1SJSM xj+A4NOzpQGNimBzFsfSgFWOYGu915jM2yKcTqIGM/s4+opCWnouZM9RRbm3FQKlUGuZAT hIsJ+D7eJ2BTEvM+13DhKSHdxFRKlI02L8NAWRrlioPN9WLZyMQFKUlNeHgbvLHq615CWW EhC3gyKEtTLsnHUR7rmy+Nlr2vl5Ts6GQ9d9lyIUX9dWBPpj2vRI4GleDBwZjn9D8cRLJg vO15CUt1nXDLNu+WtumxDmQqhACsJVQVT/8ERGEN1O+yVKdI4L2Xup4ac/TWyQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=qM70SCrs; 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: -1.61 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=qM70SCrs; 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: EDC8326055 X-Spam-Score: -1.61 X-Migadu-Scanner: scn0.migadu.com X-TUID: k7j0CSargTQI stardiviner writes: >> 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 m= acOS, so >>>> I have not tested this patch. Feel free to ignore comments from this m= essage, >>>> they are mostly matter of taste. >>>>=20 >>>> I expect that a simple script "notify-send" may allow to avoid modific= ation 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 conve= nient. >>>> 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 a= nd to >>>> drop 'gnu/linux here. From my point of view, it is preferable to avoid >>>> additional requirement for `notifications-notify'. If someone will cre= ate 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 er= ror 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 Em= acs `(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 30= 00 :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 notifi= cation > :urgency 'low))) (run-with-timer org-show-notification-timeout nil #'(lam= bda nil > (w32-notification-close id))))) ((fboundp 'notifications-notify) > (notifications-notify :title "Org mode message" :body notification :timeo= ut (* > 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. Probably some permission issue. I'll try to boot up my old mac on the weekend and see if I can get it working.=20 The other thing which also needs to be considered is whether your patch will have any adverse impact for users of the mac port of Emacs. I've been running the railwaycat emacs mac port formula from brew for ages now. It works much better than vanilla emacs on macOS. Don't know what the situation is with either dbus or integration with macOS notifications - I seem to recall something about getting closer integration using the mac ports version. I resisted the mac port of Emacs for years, believing it was better to stick to stock standard Emacs. However, when I did decide to try it out, I was surprised how much better it worked. Lots of little niggles I had with the standard Emacs under OSX/macOS just vanished. In fact, the biggest issue I had to deal with was removing all my hacky kludges I'd added over the years to make Emacs work well on the mac. Highly recommend it. --=20 Tim Cross