Skip to content

Instantly share code, notes, and snippets.

@darrenpmeyer
Last active March 5, 2020 15:20
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 darrenpmeyer/ab4c38ca3651a9268cb3310630ee3771 to your computer and use it in GitHub Desktop.
Save darrenpmeyer/ab4c38ca3651a9268cb3310630ee3771 to your computer and use it in GitHub Desktop.
Control macOS startup chime
#!/usr/bin/env bash
set -eu -o pipefail
## based on work by Mr. Macintosh: https://mrmacintosh.com/how-to-enable-the-mac-startup-chime-on-your-2016-macbook-pro/
## hattip DaringFireball: https://daringfireball.net/linked/2020/02/25/mac-startup-chime
##========================================================================
## To the extent possible under law, Darren Meyer has waived all copyright
## and related or neighboring rights to setchime.sh
##========================================================================
on='%00'
off='%01'
setting=$(nvram StartupMute|cut -f 2)
case "$setting" in
$on)
setting="on"
;;
$off)
setting="off"
;;
esac
echo "Startup Chime is currently $setting"
if [ "$setting" == "${1:-}" ]
then
echo "No change needed"
exit 0
fi
case "${1:-''}" in
on)
sudo nvram StartupMute=${on}
echo "Startup Chime is now enabled"
;;
off)
sudo nvram StartupMute=${off}
echo "Startup Chime is now disabled"
;;
*)
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment