Skip to content

Instantly share code, notes, and snippets.

@yunruse
Created February 28, 2025 12:30
Show Gist options
  • Save yunruse/c47374bc1853667563df7a17a2c4fd70 to your computer and use it in GitHub Desktop.
Save yunruse/c47374bc1853667563df7a17a2c4fd70 to your computer and use it in GitHub Desktop.
Toggle 'background sounds' in macOS
#!/usr/bin/env zsh
if [ -n "$1" ]; then
if [ "$1" -eq "1" ]; then
defaults write com.apple.ComfortSounds comfortSoundsEnabled -bool true
else
defaults write com.apple.ComfortSounds comfortSoundsEnabled -bool false
fi
# TODO: don't killall if no changes are made (it stutters)
else
# toggle
if [[ $(defaults read com.apple.ComfortSounds comfortSoundsEnabled) -eq 1 ]]; then
defaults write com.apple.ComfortSounds comfortSoundsEnabled -bool false
else
defaults write com.apple.ComfortSounds comfortSoundsEnabled -bool true
fi
fi
killall heard > /dev/null
launchctl kickstart gui/$(id -u)/com.apple.accessibility.heard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment