commit e5a0ee646a156c37db3e8022c188ad0eabb4e89c
parent 7fe126586e1464a39118f578fbd874b4e7d31ad8
Author: Alex Balgavy <alex@balgavy.eu>
Date: Wed, 8 Jun 2022 12:58:48 +0200
emacs: macos sound support & org notification
Diffstat:
3 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/dot.map b/dot.map
@@ -81,6 +81,7 @@ emacs:
- init.el: ~/.emacs.d/init.el
- jokull-theme.el: ~/.emacs.d/jokull-theme.el
- junipero-theme.el: ~/.emacs.d/junipero-theme.el
+- notification.wav: ~/.emacs.d/notification.wav
# Config: shell
shell:
diff --git a/emacs/config.org b/emacs/config.org
@@ -400,6 +400,12 @@ Link settings:
org-link-elisp-skip-confirm-regexp "^org-noter$")
#+end_src
+Clock sound:
+
+#+begin_src emacs-lisp
+ (setq org-clock-sound (concat user-emacs-directory "notification.wav"))
+#+end_src
+
*** Enable linking to email via notmuch
To be able to link to emails via notmuch, I use ol-notmuch:
@@ -1919,6 +1925,30 @@ So I create a keybinding to toggle dedicated on a window:
(org-roam-update-org-id-locations))
#+end_src
+* Sound support
+On macOS, you can use afplay:
+
+#+begin_src emacs-lisp
+ (defun za/play-sound-file-macos (file &optional volume device)
+ "Play sound using `afplay` on macOS"
+ (unless (file-readable-p file)
+ (user-error "File %s not readable." file))
+
+ ;; the `apply` is required here because I need to build a list of arguments
+ (apply 'start-process `("afplay" nil
+ "afplay"
+ ,@(if volume (list "-v" (int-to-string volume)))
+ ,file)))
+#+end_src
+
+Then redefine the play-sound-file function where needed:
+
+#+begin_src emacs-lisp
+ (cond ((and (not (fboundp 'play-sound-internal))
+ (eq system-type 'darwin))
+ (advice-add 'play-sound-file :override #'za/play-sound-file-macos)))
+#+end_src
+
* Daemon
I want to have a way to kill the Emacs daemon.
So, define a function that kills the frame, and with a prefix kills emacs.
diff --git a/emacs/notification.wav b/emacs/notification.wav
Binary files differ.