Skip to content

Instantly share code, notes, and snippets.

@ashton314
Created April 29, 2022 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashton314/4ca20e6e040f07aef58a05f42d018e23 to your computer and use it in GitHub Desktop.
Save ashton314/4ca20e6e040f07aef58a05f42d018e23 to your computer and use it in GitHub Desktop.
Play a sound after every keypress in Emacs on macOS
;; Resource: https://stackoverflow.com/questions/11206140/typewriter-sounds-for-emacs
(defvar tink "/System/Library/Sounds/Tink.aiff")
(defun play (file)
(let ((buf (get-buffer-create "playnoise")))
(start-process-shell-command "play" buf (concat "afplay " file))))
(defun do-tink ()
(play tink))
(add-hook 'post-command-hook 'do-tink)
; if you're about to die, run
; (remove-hook 'post-command-hook 'do-tink)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment