[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] make org-notify support for macOS desktop notification
From: |
Tim Cross |
Subject: |
Re: [PATCH] make org-notify support for macOS desktop notification |
Date: |
Tue, 06 Jul 2021 18:12:18 +1000 |
User-agent: |
mu4e 1.5.13; emacs 28.0.50 |
stardiviner <numbchild@gmail.com> writes:
>> On Jul 6, 2021, at 8:06 AM, Tim Cross <theophilusx@gmail.com> wrote:
>>
>>
>> stardiviner <numbchild@gmail.com> writes:
>>
>>>> On Jul 5, 2021, at 7:55 PM, Maxim Nikulin <manikulin@gmail.com> wrote:
>>>>
>>>> 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.
>>>>
>>>> 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.
>>>>
>>>> I expect that a simple script "notify-send" may allow to avoid
>>>> modification of
>>>> code. Something like (untested, unsure concerning "quoted form of ...")
>>>>
>>>> #!/usr/bin/env osascript
>>>> display notification (item 1 of argv)
>>>>
>>>> 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.
>>>>
>>>>> - ((fboundp 'notifications-notify)
>>>>> + ((and (eq system-type 'gnu/linux) (fboundp 'notifications-notify))
>>>>
>>>> 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. From 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.
>>>>
>>>>
>>> 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?
>>
>> 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 ‘dbus)` returns t.
>
> But `(org-show-notification “test”)` 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’t 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.
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.
--
Tim Cross
- [PATCH] make org-notify support for macOS desktop notification, stardiviner, 2021/07/03
- Re: [PATCH] make org-notify support for macOS desktop notification, Maxim Nikulin, 2021/07/04
- Re: [PATCH] make org-notify support for macOS desktop notification, stardiviner, 2021/07/04
- [new patch] Re: [PATCH] make org-notify support for macOS desktop notification, stardiviner, 2021/07/05
- Re: [new patch] Re: [PATCH] make org-notify support for macOS desktop notification, Christian Hopps, 2021/07/06
- Re: [new patch] [PATCH] make org-notify support for macOS desktop notification, stardiviner, 2021/07/06
- Re: [new patch] [PATCH] make org-notify support for macOS desktop notification, Christian Hopps, 2021/07/06
- Re: [new patch] [PATCH] make org-notify support for macOS desktop notification, stardiviner, 2021/07/07
- Re: [new patch] [PATCH] make org-notify support for macOS desktop notification, Christian Hopps, 2021/07/08
- STOP this patch for now., stardiviner, 2021/07/08
- Re: STOP this patch for now., Christian Hopps, 2021/07/08
- Re: [PATCH] make org-notify support for macOS desktop notification, Maxim Nikulin, 2021/07/06