mirror of
https://github.com/vale981/ement.el
synced 2025-03-05 09:21:37 -05:00
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>
This commit is contained in:
parent
82d598a22a
commit
79e8cc51f1
2 changed files with 12 additions and 4 deletions
|
@ -264,6 +264,7 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time
|
||||||
|
|
||||||
*Fixed*
|
*Fixed*
|
||||||
+ Function ~ement-room-sync~ correctly updates room-list buffers. (Thanks to [[https://github.com/vizs][Visuwesh]].)
|
+ 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
|
** 0.1.1
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,13 @@
|
||||||
(make-composed-keymap (list map button-buffer-map) 'view-mode-map))
|
(make-composed-keymap (list map button-buffer-map) 'view-mode-map))
|
||||||
"Map for Ement notification buffers.")
|
"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
|
;;;; Customization
|
||||||
|
|
||||||
(defgroup ement-notify nil
|
(defgroup ement-notify nil
|
||||||
|
@ -160,13 +167,13 @@ margins in Emacs. But it's useful, anyway."
|
||||||
|
|
||||||
(defun ement-notify (event room session)
|
(defun ement-notify (event room session)
|
||||||
"Send notifications for EVENT in ROOM on SESSION.
|
"Send notifications for EVENT in ROOM on SESSION.
|
||||||
Calls functions in `ement-notify-functions' if all of
|
Sends if all of `ement-notify-ignore-predicates' return nil.
|
||||||
`ement-notify-ignore-predicates' return nil. Does not do
|
Does not do anything if session hasn't finished initial sync."
|
||||||
anything if session hasn't finished initial sync."
|
|
||||||
(when (and (ement-session-has-synced-p session)
|
(when (and (ement-session-has-synced-p session)
|
||||||
(cl-loop for pred in ement-notify-ignore-predicates
|
(cl-loop for pred in ement-notify-ignore-predicates
|
||||||
never (funcall pred event room session)))
|
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))
|
(ement-notify--notifications-notify event room session))
|
||||||
(when (run-hook-with-args-until-success 'ement-notify-log-predicates 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))
|
(ement-notify--log-to-buffer event room session))
|
||||||
|
|
Loading…
Add table
Reference in a new issue