aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.org15
-rw-r--r--chime.el11
-rw-r--r--tests/test-chime-notify.el39
3 files changed, 17 insertions, 48 deletions
diff --git a/README.org b/README.org
index 6191078..258cabc 100644
--- a/README.org
+++ b/README.org
@@ -68,8 +68,8 @@ The quickest way to try it out:
;; Notify 5 minutes before (medium urgency) and at event time (high urgency)
(setq chime-alert-intervals '((5 . medium) (0 . high)))
- ;; Chime sound
- (setq chime-play-sound t)
+ ;; Chime sound (set to nil to disable, or to a path for a custom sound)
+ ;; (setq chime-sound-file nil)
;; Modeline display (see "Modeline Display" section for more options)
(setq chime-enable-modeline t)
@@ -211,8 +211,8 @@ Severity levels (=high=, =medium=, =low=) are passed to [[https://github.com/jwi
Control the audible chime that plays when notifications appear:
#+BEGIN_SRC elisp
- ;; Enable/disable the bundled chime sound (default: t)
- (setq chime-play-sound t)
+ ;; Disable sound entirely
+ (setq chime-sound-file nil)
;; Use your own custom sound file
(setq chime-sound-file "/path/to/your/chime.wav")
@@ -826,9 +826,8 @@ If you have custom variables that need to be available in chime's async subproce
;; Alert intervals: 5 minutes before (medium) and at event time (high)
(setq chime-alert-intervals '((5 . medium) (0 . high)))
- ;; Chime sound
- (setq chime-play-sound t)
- ;; Uses bundled chime.wav by default
+ ;; Chime sound — uses bundled chime.wav by default
+ ;; (setq chime-sound-file nil) to disable
;; Modeline display - compact format
(setq chime-enable-modeline t)
@@ -1033,7 +1032,7 @@ It also monitors event loading timing and async process performance in the backg
*** No Sound Playing
-1. Verify sound is enabled: =M-: chime-play-sound= should return =t=
+1. Verify a sound file is configured: =M-: chime-sound-file= should return a path (not nil)
2. Check sound file exists: =M-: (file-exists-p chime-sound-file)=
3. Test sound directly: =M-: (play-sound-file chime-sound-file)=
4. Ensure your system has audio support configured
diff --git a/chime.el b/chime.el
index ee08f69..930a067 100644
--- a/chime.el
+++ b/chime.el
@@ -516,13 +516,6 @@ Result: \"Upcoming Events as of Tue Nov 04 2025 @ 08:25 PM\""
:group 'chime
:type 'string)
-(defcustom chime-play-sound t
- "Whether to play a sound when notifications are displayed.
-When non-nil, plays the sound file specified in `chime-sound-file'."
- :package-version '(chime . "0.6.0")
- :group 'chime
- :type 'boolean)
-
(defcustom chime-sound-file
(expand-file-name "sounds/chime.wav"
(file-name-directory
@@ -1421,8 +1414,8 @@ MSG-SEVERITY is a cons cell (MESSAGE . SEVERITY) where MESSAGE is the
notification text and SEVERITY is one of high, medium, or low."
(let* ((event-msg (if (consp msg-severity) (car msg-severity) msg-severity))
(severity (if (consp msg-severity) (cdr msg-severity) 'medium)))
- ;; Play sound if enabled and sound file is specified
- (when (and chime-play-sound chime-sound-file)
+ ;; Play sound if a file is configured (set chime-sound-file to nil to disable)
+ (when chime-sound-file
(condition-case err
(when (file-exists-p chime-sound-file)
(play-sound-file chime-sound-file))
diff --git a/tests/test-chime-notify.el b/tests/test-chime-notify.el
index 61144c0..cd7b350 100644
--- a/tests/test-chime-notify.el
+++ b/tests/test-chime-notify.el
@@ -38,7 +38,6 @@
(setq chime-notification-title "Agenda")
(setq chime-notification-icon nil)
(setq chime-extra-alert-plist nil)
- (setq chime-play-sound t)
;; Use a simple test path for sound file
(setq chime-sound-file "/tmp/test-chime.wav"))
@@ -55,7 +54,7 @@
(let ((sound-played nil)
(alert-called nil)
(alert-message nil))
- (cl-letf* ((chime-play-sound t)
+ (cl-letf* (
(chime-sound-file (expand-file-name "test-sound.wav" chime-test-base-dir))
;; Mock file-exists-p to return t
((symbol-function 'file-exists-p) (lambda (file) t))
@@ -82,7 +81,7 @@
(unwind-protect
(let ((beep-called nil)
(alert-called nil))
- (cl-letf* ((chime-play-sound t)
+ (cl-letf* (
(chime-sound-file nil)
;; Mock beep to track if called
((symbol-function 'beep)
@@ -97,34 +96,12 @@
(should alert-called)))
(test-chime-notify-teardown)))
-(ert-deftest test-chime-notify-no-sound-when-disabled ()
- "Test that no sound is played when chime-play-sound is nil."
- (test-chime-notify-setup)
- (unwind-protect
- (let ((sound-played nil)
- (beep-called nil)
- (alert-called nil))
- (cl-letf* ((chime-play-sound nil)
- ((symbol-function 'play-sound-file)
- (lambda (file) (setq sound-played t)))
- ((symbol-function 'beep)
- (lambda () (setq beep-called t)))
- ((symbol-function 'alert)
- (lambda (msg &rest args) (setq alert-called t))))
- (chime--notify "Daily Standup")
- ;; Should NOT play sound or beep
- (should-not sound-played)
- (should-not beep-called)
- ;; Should still show alert
- (should alert-called)))
- (test-chime-notify-teardown)))
-
(ert-deftest test-chime-notify-passes-correct-parameters-to-alert ()
"Test that alert is called with correct parameters."
(test-chime-notify-setup)
(unwind-protect
(let ((alert-params nil))
- (cl-letf* ((chime-play-sound nil)
+ (cl-letf* (
(chime-notification-title "Custom Title")
(chime-notification-icon "/path/to/icon.png")
(chime-extra-alert-plist '(:persistent t))
@@ -150,7 +127,7 @@
(unwind-protect
(let ((alert-called nil)
(alert-message nil))
- (cl-letf* ((chime-play-sound nil)
+ (cl-letf* (
((symbol-function 'alert)
(lambda (msg &rest args)
(setq alert-called t)
@@ -167,7 +144,7 @@
(unwind-protect
(let ((sound-played nil)
(alert-called nil))
- (cl-letf* ((chime-play-sound t)
+ (cl-letf* (
(chime-sound-file "/nonexistent/path/sound.wav")
;; Mock file-exists-p to return nil
((symbol-function 'file-exists-p) (lambda (file) nil))
@@ -189,7 +166,7 @@
(test-chime-notify-setup)
(unwind-protect
(let ((alert-called nil))
- (cl-letf* ((chime-play-sound t)
+ (cl-letf* (
(chime-sound-file "/some/file.wav")
;; Mock file-exists-p to return t
((symbol-function 'file-exists-p) (lambda (file) t))
@@ -211,7 +188,7 @@
(test-chime-notify-setup)
(unwind-protect
(let ((alert-called nil))
- (cl-letf* ((chime-play-sound t)
+ (cl-letf* (
(chime-sound-file nil)
;; Mock beep to throw error
((symbol-function 'beep)
@@ -231,7 +208,7 @@
(test-chime-notify-setup)
(unwind-protect
(let ((alert-called nil))
- (cl-letf* ((chime-play-sound nil)
+ (cl-letf* (
((symbol-function 'alert)
(lambda (msg &rest args) (setq alert-called t))))
;; Should not error with nil message