Sound often randomly disappears from menu bar
System Preferences > Show volume in menu bar often randomly unchecks itself since upgrading to Big Sur.
Very annoying to look to change my volume or sound output, then find it missing from the menu bar.
How can I stop this from happening?
System Preferences > Show volume in menu bar often randomly unchecks itself since upgrading to Big Sur.
If it's a bug, I would provide feedback to Apple at: https://www.apple.com/feedback/macos.html
How can I stop this from happening?
If under System Preferences > Dock & Menu Bar > Sound > Show in Menu Bar is checked and set to [always], not [when active], then sorry no, I do not know how to stop it from happening, however, I can offer a workaround that will automatically restore the icon to the menu bar when it disappears.
This is done using a Launch Agent and a shell script using osascript
to run some AppleScript code that will click the checkbox with it gets unchecked.
In Terminal, assuming the pwd
is your Home directory:
touch checkSoundMenu; open -e checkSoundMenu; chmod +x checkSoundMenu
Copy and paste the following example shell script code into the opened checkSoundMenu document and then save and close the document.
Back in Terminal:
sudo mv -v checkSoundMenu /usr/local/bin/
sudo -k
Example shell script/AppleScript code:
#!/usr/bin/osascript
set thePropertyListFilePath to POSIX path of ¬
(path to preferences from user domain) & ¬
"com.apple.controlcenter.plist"
tell application "System Events" to ¬
tell property list file thePropertyListFilePath to ¬
set soundIsVisible to value of ¬
property list item "NSStatusItem Visible Sound"
if soundIsVisible then
return
else
if running of application "System Preferences" then
try
tell application "System Preferences" to quit
on error
do shell script "killall 'System Preferences'"
end try
delay 0.1
end if
repeat while running of application "System Preferences" is true
delay 0.1
end repeat
tell application "System Preferences"
run
set current pane to pane id "com.apple.preference.sound"
end tell
tell application "System Events"
tell front window of application process "System Preferences"
repeat until (exists checkbox "Show volume in menu bar")
delay 0.01
end repeat
click checkbox "Show volume in menu bar"
delay 0.1
end tell
end tell
tell application "System Preferences" to quit
end if
With the shell script taken care of, create the Launch Agent in Terminal, assuming the pwd
is your Home directory:
cd Library
[ ! -d LaunchAgents ] && mkdir LaunchAgents
cd LaunchAgents
touch com.my.menu.bar.sound.plist
open -e com.my.menu.bar.sound.plist
Copy and paste the following example XML Plist code into the opened com.my.menu.bar.sound.plist document and change you
in the value for WatchPaths to your Home directory, then save and close the document.
Back in Terminal:
launchctl load com.my.menu.bar.sound.plist
Example XML Plist code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.my.menu.bar.sound</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/checkSoundMenu</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>WatchPaths</key>
<array>
<string>/Users/you/Library/Preferences/com.apple.controlcenter.plist</string>
</array>
</dict>
</plist>
Notes:
The use of this workaround will require changes to System Preferences > Security & Privacy > Privacy > Accessibility in that osascript needs to be added and checked. You should be prompted for this when the checkSoundMenu shell script runs for the first time when the com.apple.controlcenter.plist file is changed, e.g.:
-
"osascript" wants access to control "System Preferences" Allowing control will provide access to documents and data in "System Preferences" and to perform actions within that app. -- Click: [OK]
-
"osascript" wants access to control "System Events". Allowing control will provide access to documents and data in "System Events" and to perform actions within that app. -- Click: [OK]
-
"osascript" would like to control this computer using accessibility features. Grant access to this application in Security & Privacy preferences, located in System Preferences. -- Click: [Open System Preferences]
- Click the Lock, enter your credentials, and check: [√] osascript
You should of course trigger this manually the first time by unchecking the Show volume in menu bar checkbox in: System Preferences > Sound
I would toggle it a couple of times to make sure the Launch Agent is working as desired so when it does trigger naturally it works as expected.
This was tested and worked for me in macOS Big Sur with System Preferences > Language & Region set to English (US).
Reverting Changes
To completely undo the changes made by this, in Terminal:
cd ~/Library/LaunchAgents
launchctl unload com.my.menu.bar.sound.plist
rm com.my.menu.bar.sound.plist
cd /usr/local/bin
sudo rm checkSoundMenu
In System Preferences > Security & Privacy > Privacy > Accessibility uncheck and remove osascript if not being used otherwise.