toggling background sound / white noise with BTT?

apologies if this has been asked before, but I cannot find it here in the forums, so here we go:

is there a way to use BTT to toggle background sound (white noise) in the accessability settings?

you can use the "Run Apple Script" action with this script, it will toggle background sounds on / off:

-- Returns true if Background Sounds are enabled, false otherwise
on isBackgroundSoundsEnabled()
    try
        set enabledValue to do shell script "defaults read com.apple.ComfortSounds comfortSoundsEnabled"
        return (enabledValue = "1")
    on error
        return false
    end try
end isBackgroundSoundsEnabled

-- Enable or disable Background Sounds and notify the daemon
on setBackgroundSoundsState(enabled)
    set boolArg to enabled as string
    set writeCmd to "defaults write com.apple.ComfortSounds comfortSoundsEnabled -bool " & boolArg
    if enabled then
        set writeCmd to writeCmd & "; defaults write com.apple.ComfortSounds lastEnablementTimestamp $(date +%s)"
    end if
    do shell script writeCmd
    do shell script "killall -HUP heard"
end setBackgroundSoundsState

-- Toggle Background Sounds
if isBackgroundSoundsEnabled() then
    setBackgroundSoundsState(false)
else
    setBackgroundSoundsState(true)
end if

1 Like

excellent - thank you very much, I'll try that right away!..:slight_smile: