Posted on 11-18-2020 08:04 AM
We have a set of scripts that keep all devices CIS compliant.
On Catalina this snippet ensured the bluetooth menu was visible.
#!/bin/bash
#CIS 2.1.3 enable bluetooth menu bar
if [[ "$loggedInUser" != "root" ]] && [[ "$loggedInUID" -ne 0 ]]; then
btMenuBar="$(defaults read /Users/"$loggedInUser"/Library/Preferences/com.apple.systemuiserver menuExtras | grep -c Bluetooth.menu)"
if [ "$btMenuBar" = "0" ]; then
sudo -u $loggedInUser open "/System/Library/CoreServices/Menu Extras/Bluetooth.menu"
fi
fi
Post Big Sur upgrade the /System/Library/CoreServices/Menu Extras/Bluetooth.menu file no longer exists and although I do see a bluetooth menu item on my screen, I can not for the life of me figure out how to open it from the command line.
Any suggestions?
Posted on 11-18-2020 08:45 AM
I haven't been able to test anything yet, but a user named @mikelaundrie posted on another thread that some of the missing menu bar items might now exist in the com.apple.controlcenter.plist
file. See here:
https://www.jamf.com/jamf-nation/discussions/10576/menu-bar-customization#responseChild209331
Posted on 11-18-2020 08:54 AM
I saw the same in our environment. I guess it's because of the new control center. There is a plist file called com.apple.controlcenter in the same folder. You will have the same issue with the Wi-Fi symbol and the CIS 4.2
Edit: There was someone faster than me :) I tested it, but it is still not working for me.
Posted on 12-01-2020 07:39 AM
Diving a little deeper it looks like modifying the ~/Library/Preferences/ByHosts preference for the control center seems to do the trick. I'm a bit concerned that there might be more to these integer values than meets the eye, but it's worth testing, so I wanted to put it out there. Here's the code to show bluetooth in the menu bar
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter.plist Bluetooth -int 18
Changing the int to 24 will hide it. Changing it to 1 will also hide it. changing it to 2 will also show it. Please give it a whirl and let me know how it works for you.
Posted on 12-01-2020 12:25 PM
Thought I was going mad!!! Nothing showed on Google searches
Posted on 12-14-2020 09:14 AM
This no longer seems to work again
Script result: 2020-12-14 17:09:14.422 defaults[2040:13293]
The domain/default pair of (/Users/lewis/Library/Preferences/ByHost/com.apple.controlcenter.plist, Bluetooth) does not exist
Posted on 12-14-2020 09:31 AM
As some others have mentioned, this can now be found in the com.apple.controlcenter plist. I have also confirmed that Wifi and Volume also work in this plist.
Posted on 12-14-2020 09:42 AM
@cbutcher My post clearly shows I was referring to com.apple.controlcenter.plist :)
sudo -u ${loggedInUser} defaults write /Users/${loggedInUser}/Library/Preferences/ByHost/com.apple.controlcenter.plist Bluetooth -int 18
Script result: 2020-12-14 17:09:14.422 defaults[2040:13293] The domain/default pair of (/Users/lewis/Library/Preferences/ByHost/com.apple.controlcenter.plist, Bluetooth) does not exist
Posted on 01-06-2021 01:51 PM
This is working for me, running this script in self service.
currentUser=$( ls -l /dev/console | awk '{print $3}' )
sudo -u ${currentUser} defaults write /Users/${currentUser}/Library/Preferences/ByHost/com.apple.controlcenter.plist Bluetooth -int 18
exit 0
Posted on 02-22-2021 09:32 AM
@agagnon is this script still working for you? I tried it and Bluetooth icon is still in control center.
Tried @joebesser command suggestion but that did not work for me either.
Anyone else got something working to remove icons from Control Center or the entire control center icon from the menu bar itself?
Posted on 02-22-2021 09:39 AM
@apatel The script works for me but it needs a restart before it takes effect.
Posted on 04-13-2021 02:37 PM
I've managed to use @agagnon code for the Bluetooth icon on the Menu Bar in Big Sur, which works fine for me.
Does anyone know how to show the battery percentage on the Menu Bar in Big Sur via a script? I've got the below script for Catalina however this doesn't work with Big Sur.
currentUser=`ls -l /dev/console | cut -d " " -f4`
sudo -u $currentUser defaults write com.apple.menuextra.battery ShowPercent YES
sudo -u $currentUser killall SystemUIServer
Posted on 05-14-2021 08:54 AM
@Tomsmithdrpg This command enables the battery percent without the need to run the kill all. Seems to just work instantly:
~/Library/Preferences/ByHost/com.apple.controlcenter.plist BatteryShowPercentage -bool true
Gabe Shackney
Princeton Public Schools
Posted on 06-08-2021 08:35 AM
Sorry for hijacking the post again but managed to get the Battery Percentage to finally show on the Menu Bar in Big Sur. Thanks @gshackney for your help I managed to put something together from few different sources and using your suggestion above.
Hopefully, this helps someone else out in the future, ran as a once per computer script for Big Sur devices.
#!/bin/bash
_user=`who | grep console | awk '{ print $1 }'`
sudo -u $_user defaults write /Users/$_user/Library/Preferences/ByHost/com.apple.controlcenter.plist BatteryShowPercentage -bool true
Posted on 09-01-2021 07:42 AM
Thank You!