-
-
Save 0xbb/ae298e2798e1c06d0753 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
printf "\x07\x00\x00\x00\x00" > /sys/firmware/efi/efivars/SystemAudioVolume-7c436110-ab2a-4bbb-a880-fe41995c9f82 |
If someone else finds this Gist: You need to remove the immutable flag before writing.
chattr -i /sys/firmware/efi/efivars/SystemAudioVolume-7c436110-ab2a-4bbb-a880-fe41995c9f82
I've been looking all over the web, all day, for a solution to this--> jradmacher you're a genius. Thank you thank you!
Genius, thank you!
try just doing su before doing printf
its a pretty sensitive directory so it could be that your distro is being a bit extra cautious?
If anyone needs :)
#!/usr/bin/bash
# Mute MacBook Chime
## Make "chime" value mutable
sudo chattr -i /sys/firmware/efi/efivars/SystemAudioVolume-7c436110-ab2a-4bbb-a880-fe41995c9f82
## Change "chime" value to "muted"
sudo printf "\x07\x00\x00\x00\x00" > /sys/firmware/efi/efivars/SystemAudioVolume-7c436110-ab2a-4bbb-a880-fe41995c9f82
## Make "chime" value immutable again
sudo chattr +i /sys/firmware/efi/efivars/SystemAudioVolume-7c436110-ab2a-4bbb-a880-fe41995c9f82
printf "\nποΈποΈ Now you don't have startup chime anymore!"
Also, anyone knows is there a way to enable it back? (just want to know)
I found that I had to specifically install efivar
before the SystemAudioVolume variable was available. I also had to run @daudix-UFO 's script as root (via sudo su
) as anything done as sudo
didn't work.
@daudix-UFO to reenable it, just clear the nvram. Cmd + Options + P + R at the same time right on boot. Hold it for 20 seconds, the mac will reboot a couple times. And now you have that startling sound again π€£. At least this is what i got with a 2012 iMac.
I have a MacBook9,1
and a MacBookPro14,1
-- and on both of these models I needed to set the hex value to 80
Setting it to 00
did not work. I'm surprised no one has posted anything on this topic before.....
printf "\x07\x00\x00\x00\x80" > SystemAudioVolume-7c436110-ab2a-4bbb-a880-fe41995c9f82
# probably wasn't needed, but changed the value of SystemAudioVolumeDB to match SystemAudioVolume
printf "\x07\x00\x00\x00\x80" > SystemAudioVolumeDB-7c436110-ab2a-4bbb-a880-fe41995c9f82
it only worked when i use yours @leifliddy π«‘,thanks
on MacBookPro13,1
i didn't need to overwrite the SystemAudioVolumeDB-*
one
Thanks @leifliddy ! After searching and trying to disable the startup chime / gong on my 2017 5K iMac 18,3 your trick of using 80 instead of 0 works great! Here's the script I use. I also put it in root's crontab @reboot to ensure it's always muted.
#!/bin/bash
#Ensure that we are root
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
#Turn off the startup gong chime sound of a 2017 5K iMac 18,3 using Linux (Gentoo)
echo
echo ----------------------------------------------------------------
efivar -n "7c436110-ab2a-4bbb-a880-fe41995c9f82-SystemAudioVolume" -p # print
echo ----------------------------------------------------------------
echo "Before: $(efivar -n "7c436110-ab2a-4bbb-a880-fe41995c9f82-SystemAudioVolume" -d)" # print decimal
echo ----------------------------------------------------------------
#Remove the immutable flag before writing.
chattr -i "/sys/firmware/efi/efivars/SystemAudioVolume-7c436110-ab2a-4bbb-a880-fe41995c9f82"
#Set it to 80 instead of 0
printf "\x07\x00\x00\x00\x80" > "/sys/firmware/efi/efivars/SystemAudioVolume-7c436110-ab2a-4bbb-a880-fe41995c9f82"
#make it immutable again
chattr +i "/sys/firmware/efi/efivars/SystemAudioVolume-7c436110-ab2a-4bbb-a880-fe41995c9f82"
echo "After : $(efivar -n "7c436110-ab2a-4bbb-a880-fe41995c9f82-SystemAudioVolume" -d)" # print decimal
echo ----------------------------------------------------------------
echo
@daudix THX SO MUCH π©π©π©π©π©
@P2AK Worked as a charm, thank you.
@daudix it works! thank you very much!
Also, anyone knows is there a way to enable it back? (just want to know)
Yes
sudo rm /sys/firmware/efi/efivars/SystemAudioVolume-7c436110-ab2a-4bbb-a880-fe41995c9f82
sudo rm /sys/firmware/efi/efivars/SystemAudioVolume-7c436110-ab2a-4bbb-a880-fe41995c9f82
Or just reset the P-RAM, but that also resets the boot chime volume.
Does anyone in this thread know if it's still completely unknown how to modify the volume of the boot chime from Linux? I looked around off and on for years but never found any references to how to change the startup sound volume, except by booting into some installed version of macOS, changing the volume, and then shutting down the Mac the normal way so that the volume change gets saved in NVRAM.
The NVRAM variable is called "SystemAudioVolume", but the techniques here and on the web only seem capable of muting or unmuting the startup sound. Would be nice to be able to just make it quieter without involving macOS.
@RedBearAK that's precisely the point of this thread. Read again. I just did it on two imac 2011.
that's precisely the point of this thread. Read again. I just did it on two imac 2011.
What are you talking about? I've never seen a reference anywhere on the web, including in this thread, about how to change the volume LEVEL of the boot chime, not just mute (off) or unmute (on, at whatever volume the system thinks is the default).
Please quote something in this thread that you think explains how to freely adjust the volume LEVEL of the boot chime, instead of muting it entirely. Or even an explanation of what different values in the example string ("\x07\x00\x00\x00\x80") might do, and how to safely experiment with other values to perhaps change the boot chime volume level.
If anyone is interested, I finally figured out how to control the volume of the startup sound. I think the key was the fact that everyone started successfully using \x80
instead of \x00
in the last byte of the value being written to the EFI variable. This allowed Claude (the LLM) to do some web research and surmise that the last byte is using bit packing for encoding dual purposes. It's controlling both on/off state of the boot chime with the Most Significant Bit (i.e., 10000000 vs 00000000) and also has the possibility to save the volume level in the remaining seven binary bits, which allows storing values from 0-127 for volume control.
(i.e., 00000000 to 01111111 if unmuted, or 10000000 to 11111111 if muted)
So the \x80
is storing 128 as the controlling value in the MSB, which mutes the boot chime, while \x00
was just turning the volume down (not sure why that stopped working for some, perhaps the zero value started being ignored on some machines as an invalid volume level). But you can set the same byte to a value like 192, and then "unmute" the boot chime and restore it to a value of 64 (50% volume). That is, 192 = 128 + 64. The most significant bit is just an on/off mask. Any value over 127 ends up muting the boot chime. This is my understanding of what's going on.
I used Claude to build up a comprehensive script to handle all the different things that can be done with this information. I've tried the script on an iMac12,2 and MacBookPro5,5 with all sorts of settings. No ill effects were observed, and it definitely allows controlling the startup sound volume, not just muting or unmuting. With unmuting, the lower seven bits will be checked by the script for a stored volume level to restore, or it defaults to 50%. Muting will add 128 to the current volume level, if there is one.
The 0-127 value range is a little odd once you go below 64, where the smaller values result in a very low volume well before getting to even a value of 32, which is getting close to inaudible on the machines I've tested. I'd suggest starting with 64 if you want a somewhat "quiet" boot chime, or 56 if you have a pretty quiet room. I get the feeling that when you reset the NVRAM it defaults to max volume (127). That's why the boot chime seems so obnoxiously loud whenever you do a PRAM/NVRAM reset.
I added the script to my keymapper project (Toshy) that I use to bring Mac-style keyboard shortcuts to any Mac or PC on which I use Linux. I would be really interested in any feedback on the script, although if you run into a problem with it or want a new feature, you should probably submit an issue for discussion on the Toshy repo:
https://github.com/RedBearAK/toshy/issues/
To download just the script separately from the Toshy project, just go here:
https://github.com/RedBearAK/toshy/blob/main/scripts/set-mac-startup-sound-volume.sh
Save the script (there's a "Download Raw File" button next to where it says "Raw") and make sure you set the file as executable and run it as root, like so:
chmod +x ./set-mac-startup-sound-volume.sh
sudo ./set-mac-startup-sound-volume.sh
Without an argument it will show the usage options/commands, which are things like this:
sudo ./set-mac-startup-sound-volume.sh info
sudo ./set-mac-startup-sound-volume.sh mute
sudo ./set-mac-startup-sound-volume.sh unmute
sudo ./set-mac-startup-sound-volume.sh 64
There's also a "reset" command that just deletes the EFI variable, similar to doing a PRAM/NVRAM reset, but without resetting the whole NVRAM. The boot chime then ends up with the expected default loudness at the next boot.
Hey, this doesn't work, since not even root has the permission to change these :/
Could you lend your help here?