I want to disable the Bluetooth Sharing that is located in the sharing preference section. I want to be able to disable it via terminal, does anyone have an idea on how to do that?
Asked
Active
Viewed 4,884 times
2
-
maybe this will help you http://apple.stackexchange.com/questions/47503/how-to-control-bluetooth-wireless-radio-from-the-command-line – Ruskes Mar 31 '15 at 15:41
-
@Buscar웃 that seems to be just to disable bluetooth, I want to disable the sharing feature. – Technic1an Mar 31 '15 at 15:45
-
This set of commands may help by disabling Bluetooth Discoverable Mode. – IconDaemon Mar 31 '15 at 16:15
-
The .pref file is located at ~/Library/Preferences/ByHost/com.apple.Bluetooth.
.plist, and the specific property in the .plist is PrefKeyServicesEnabled. Toggling Bluetooth Sharing on and off in the Sharing Pref pane off changes the boolean value of this property in the .plist file. Kicking OS X to actually make the change I'm still investigating. – IconDaemon Mar 31 '15 at 16:43 -
@IconDaemon I dont seem to see this inside of the plist file. Have you discovered anything else? – Technic1an Mar 31 '15 at 19:59
-
Haven't discovered anything yet. I'm running Yosemite on my Mac and I see this value toggle back and forth in the .plist whenever I check (and uncheck) the checkbox. Perhaps Mavericks did it differently. One thing to help find out what files are changing is to have the both the Preferences folder and the ByHost folder open in separate windows, sorted by date with newest first. Then turn on (or off) Bluetooth Sharing, close the Sharing Prefpane, and see what files have been modified in both folders. This is how I found the PrefKeyServicesEnabled property. Good luck! – IconDaemon Mar 31 '15 at 22:03
1 Answers
2
This is what I'm using for Yosemite:
First, grab $hardwareUUID:
hardwareUUID=$(/usr/sbin/system_profiler SPHardwareDataType | grep "Hardware UUID" | awk -F ": " '{print $2}')
Then loop through existing users and set to "Disabled"
for USER_HOME in /Users/*
do
USER_UID=`basename "${USER_HOME}"`
if [ ! "${USER_UID}" = "Shared" ]
then
if [ ! -d "${USER_HOME}"/Library/Preferences ]
then
mkdir -p "${USER_HOME}"/Library/Preferences
chown "${USER_UID}" "${USER_HOME}"/Library
chown "${USER_UID}" "${USER_HOME}"/Library/Preferences
fi
if [ ! -d "${USER_HOME}"/Library/Preferences/ByHost ]
then
mkdir -p "${USER_HOME}"/Library/Preferences/ByHost
chown "${USER_UID}" "${USER_HOME}"/Library
chown "${USER_UID}" "${USER_HOME}"/Library/Preferences
chown "${USER_UID}" "${USER_HOME}"/Library/Preferences/ByHost
fi
if [ -d "${USER_HOME}"/Library/Preferences/ByHost ]
then
/usr/libexec/PlistBuddy -c "Delete :PrefKeyServicesEnabled" "$USER_HOME"/Library/Preferences/ByHost/com.apple.Bluetooth.$hardwareUUID.plist
/usr/libexec/PlistBuddy -c "Add :PrefKeyServicesEnabled bool false" "$USER_HOME"/Library/Preferences/ByHost/com.apple.Bluetooth.$hardwareUUID.plist
chown "${USER_UID}" "${USER_HOME}"/Library/Preferences/ByHost/com.apple.Bluetooth.$hardwareUUID.plist
fi
fi
done
If you just want the chunk that actually disables the value, see below:
/usr/libexec/PlistBuddy -c "Delete :PrefKeyServicesEnabled" "$USER_HOME"/Library/Preferences/ByHost/com.apple.Bluetooth.$hardwareUUID.plist
/usr/libexec/PlistBuddy -c "Add :PrefKeyServicesEnabled bool false" "$USER_HOME"/Library/Preferences/ByHost/com.apple.Bluetooth.$hardwareUUID.plist
chown "${USER_UID}" "${USER_HOME}"/Library/Preferences/ByHost/com.apple.Bluetooth.$hardwareUUID.plist
Haley Isadog
- 21