I'm attempting to create a script for muting the system volume which gets triggered upon logging out or shutting down. This is to avoid hearing the startup chime really loudly the next time I start the machine.

Using the instructions provided in this post, I have created a RunAtLoad launch agent that calls the script shown below:

#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail


onLogout ()
    osascript -e "set volume output volume 0"


while true; do
    say starting
    sleep 86400 &
    wait $!

The idea being that the script is called and made to sleep until it receives one of the trapped signals, at which point the onLogout function is called in order to mute the volume.

Currently it's not working as intended, the volume remains unchanged when I log out and log back in. However, I've found that if I manually unload the launch agent that launches the script (using a launchctl unload call), then it works perfectly. The system volume is muted immediately.

Initially I thought perhaps the trapped signals weren't being received by the script when I performed a logout. But after adding some debugging code to the onLogout function as shown below, I have eliminated this as a possible cause.

onLogout ()
    printf "Before mute\n" >> ~/Desktop/log.txt
    osascript -e "set volume output volume 0"
    printf "After mute\n" >> ~/Desktop/log.txt

When I performed a logout, and logged back in, there was a "log.txt" file on the desktop with both of the Before mute and After mute debugging lines present.

And I don't believe the reason is that the osascript call for performing the muting is somehow failing when a logout is carried out. Due to the set -o errexit line in the script, if any part of the script fails, then it should halt execution and exit immediately. This means that if the muting operation is failing, I shouldn't be seeing the After muting line in my log file. Indeed, when I tested this by replacing the osascript line with something I knew was guaranteed to fail, the log contained only the Before muting line as expected.

I'm at a loss to explain what's going on. Clearly the onLogout function is being called correctly as explained above, but for some reason the osascript call seems to only run when I manually unload using launchctl. When I log out manually it just skips over it somehow.

Any help would be greatly appreciated.

1 Answer 1


In Terminal, execute the following command to disable the chime completely until reenabled:

sudo nvram SystemAudioVolume=%80

If this setting is not retained, try:

sudo nvram SystemAudioVolume=%01

sudo nvram SystemAudioVolume=%00


sudo nvram SystemAudioVolume=" "

To reenable the chime:

sudo nvram -d SystemAudioVolume

Info gleaned from:



  • This works. Most of the time. I have this value set and was greeted this morning with a booming chime noise. Can you specify when this value gets overridden or ignored? Nov 1, 2017 at 19:36
  • Hmmm. It should stay with that setting. I've added other commands to my answer to try if %80 doesn't work.
    – IconDaemon
    Nov 1, 2017 at 19:40
  • At one point or another I tried them all. nvram -p currently lists %80. The last dozn or so boots were silent. They all seem to be working only 99% percent of time. What about SystemAudioVolumeDB? That value changes arbitrarily. Nov 1, 2017 at 19:44
  • What version of OS X / macOS are you folks running? I can't get this to work on Sierra. I've tried all of the variations for values (%80, %01, %00, " "), but I get the chime each time. %80 seems to be the magic value though, since when I manually mute the system volume and then restart (which so far is the only surefire way to have no chime), nvram reports %80 for both SystemAudioVolume and SystemAudioVolumeDB. But the problem is that these values get reset to : and %e4 respectively whenever I restart or shutdown without having first muted the volume myself. Nov 2, 2017 at 9:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .