Last active
March 5, 2020 15:20
-
-
Save darrenpmeyer/ab4c38ca3651a9268cb3310630ee3771 to your computer and use it in GitHub Desktop.
Control macOS startup chime
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 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