[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ement 79e8cc51f1 5/5: Fix: (ement-notify) Ensure D-Bus
From: |
ELPA Syncer |
Subject: |
[elpa] externals/ement 79e8cc51f1 5/5: Fix: (ement-notify) Ensure D-Bus is available |
Date: |
Fri, 9 Sep 2022 13:57:37 -0400 (EDT) |
branch: externals/ement
commit 79e8cc51f104b35246e73c434a024f5635ddca5f
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>
Fix: (ement-notify) Ensure D-Bus is available
Adds (ement-notify-dbus-p).
Fixes #83. Thanks to Tassilo Horn (@tsdh) for reporting and providing
the predicate code.
Reported-by: Tassilo Horn <tsdh@gnu.org>
Suggested-by: Tassilo Horn <tsdh@gnu.org>
Co-authored-by: Tassilo Horn <tsdh@gnu.org>
---
README.org | 1 +
ement-notify.el | 15 +++++++++++----
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/README.org b/README.org
index 62ea2ab0af..dae3b70e17 100644
--- a/README.org
+++ b/README.org
@@ -264,6 +264,7 @@ Note that, while ~matrix-client~ remains usable, and
probably will for some time
*Fixed*
+ Function ~ement-room-sync~ correctly updates room-list buffers. (Thanks to
[[https://github.com/vizs][Visuwesh]].)
++ Only send D-Bus notifications when supported. (Fixes
[[https://github.com/alphapapa/ement.el/issues/83][#83]]. Thanks to
[[https://github.com/tsdh][Tassilo Horn]].)
** 0.1.1
diff --git a/ement-notify.el b/ement-notify.el
index 6107531cdf..2b0016021d 100644
--- a/ement-notify.el
+++ b/ement-notify.el
@@ -48,6 +48,13 @@
(make-composed-keymap (list map button-buffer-map) 'view-mode-map))
"Map for Ement notification buffers.")
+(defvar ement-notify-dbus-p
+ (and (featurep 'dbusbind)
+ (require 'dbus nil :no-error)
+ (dbus-ignore-errors (dbus-get-unique-name :session))
+ (dbus-ping :session "org.freedesktop.Notifications"))
+ "Whether D-Bus notifications are usable.")
+
;;;; Customization
(defgroup ement-notify nil
@@ -160,13 +167,13 @@ margins in Emacs. But it's useful, anyway."
(defun ement-notify (event room session)
"Send notifications for EVENT in ROOM on SESSION.
-Calls functions in `ement-notify-functions' if all of
-`ement-notify-ignore-predicates' return nil. Does not do
-anything if session hasn't finished initial sync."
+Sends if all of `ement-notify-ignore-predicates' return nil.
+Does not do anything if session hasn't finished initial sync."
(when (and (ement-session-has-synced-p session)
(cl-loop for pred in ement-notify-ignore-predicates
never (funcall pred event room session)))
- (when (run-hook-with-args-until-success
'ement-notify-notification-predicates event room session)
+ (when (and ement-notify-dbus-p
+ (run-hook-with-args-until-success
'ement-notify-notification-predicates event room session))
(ement-notify--notifications-notify event room session))
(when (run-hook-with-args-until-success 'ement-notify-log-predicates event
room session)
(ement-notify--log-to-buffer event room session))