2

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?

6
  • maybe this will help you apple.stackexchange.com/questions/47503/…
    – Ruskes
    Mar 31, 2015 at 15:41
  • @Buscar웃 that seems to be just to disable bluetooth, I want to disable the sharing feature.
    – Technic1an
    Mar 31, 2015 at 15:45
  • This set of commands may help by disabling Bluetooth Discoverable Mode.
    – IconDaemon
    Mar 31, 2015 at 16:15
  • The .pref file is located at ~/Library/Preferences/ByHost/com.apple.Bluetooth.<HardwareUUID>.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, 2015 at 16:43
  • @IconDaemon I dont seem to see this inside of the plist file. Have you discovered anything else?
    – Technic1an
    Mar 31, 2015 at 19:59

1 Answer 1

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       

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .