Trying to get BT icon to show on Menu via command

SMR1
Contributor III

Part of our Mac hardening, we have to have the BT icon show on the menu bar. All our Mac's are mostly Ventura with a handful of Sonoma. I don't see anything in to Jamf to allow this. I have a command that when ran locally via terminal, it'll add the icon, but if I create a policy using the Files and Processes>Execute Command, it won't add it, but the according to the log on the device, it was successful.  I've also tried using a script, but the script won't add it either.

defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter.plist Bluetooth -int 2

1 ACCEPTED SOLUTION

dmccluskey
Contributor

This is what I use to enable BT in the menu bar. I believe it shows after reboot.

Screenshot 2024-01-03 at 12.25.07 PM.png

#!/bin/bash

loggedInUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')
#hostId=$(system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -d ":" -f2 | xargs)
sudo -u "$loggedInUser" defaults write "/Users/$loggedInUser/Library/Preferences/ByHost/com.apple.controlcenter.plist" Bluetooth -int 18

View solution in original post

3 REPLIES 3

mm2270
Legendary Contributor III

You can't do anything like defaults write ~ from a Jamf policy, because the ~ in that command means it will work on the user directory of the account running the command, and in this case from a Jamf policy, it will be root, not the logged in user.

While it's not hard to adjust your script to affect the logged in user, I suggest using a Configuration Profile to enable the Bluetooth icon in the menubar, which will make it persistent through reboots, but will still allow users to add/remove other icons to the menu bar. If you have the Bluetooth Preference Pane opened to them, they'll be able to remove it from the menubar using the checkbox located in it, but as I said, it will come back up after a restart or logout/login.

Something like this added to an Application and Custom Settings payload will do it.

<?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>menuExtras</key>
	<array>
		<string>/System/Library/CoreServices/Menu Extras/Bluetooth.menu</string>
	</array>
</dict>
</plist>

You can add other menu items in there if needed, or just leave BT as the only one.

The domain to apply this to is: com.apple.systemuiserver

dmccluskey
Contributor

This is what I use to enable BT in the menu bar. I believe it shows after reboot.

Screenshot 2024-01-03 at 12.25.07 PM.png

#!/bin/bash

loggedInUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')
#hostId=$(system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -d ":" -f2 | xargs)
sudo -u "$loggedInUser" defaults write "/Users/$loggedInUser/Library/Preferences/ByHost/com.apple.controlcenter.plist" Bluetooth -int 18

danlaw777
Contributor III

Check out the Jamf compliance editor here : https://trusted.jamf.com/docs/establishing-compliance-baselines 

it works wonders! LOL (Thats my mom talking) its an easy step by step guide that made my security team very happy with our mac standardization