Created
February 28, 2025 12:30
-
-
Save yunruse/c47374bc1853667563df7a17a2c4fd70 to your computer and use it in GitHub Desktop.
Toggle 'background sounds' in macOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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