Category filter

Script to show Bluetooth menu on status bar of macOS devices

This document helps you display the Bluetooth menu on status bar of macOS devices with the help of a script.

Displaying the Bluetooth status on the menu bar on macOS devices can be a convenient way to check the status of your Bluetooth connection and easily toggle it on or off as needed. This feature allows you to easily check if Bluetooth is enabled or not, whether it is discoverable to other devices, what paired devices exist, and which paired devices are currently active, all without navigating to the device settings. IT admins can use Hexnode’s Execute Custom Script action to execute the script provided below to display the Bluetooth menu on the status bar on macOS devices.

Scripting language – Bash

File extension – .sh

Disclaimer:

The sample scripts provided below are adapted from third-party open-source sites.

Pre-requisites:

The script works on devices running macOS 11.7.10 and later.

To show Bluetooth status on the menu bar

The provided Bash script retrieves the username and user ID of the currently logged-in user on the macOS device, and then uses the defaults command to modify the Bluetooth key in the com.apple.controlcenter.plist property list file for the current host. The value of the key is set to 18, which enables the Bluetooth status to be displayed on the menu bar of macOS devices.

To hide Bluetooth status on the menu bar

The provided Bash script retrieves the username and user ID of the currently logged-in user on the macOS device, and then uses the defaults command to modify the Bluetooth key in the com.apple.controlcenter.plist property list file for the current host. The value of the key is set to 0, which hides the Bluetooth status on the menu bar of macOS devices.

What happens at the device end?

With the execution of this script, the Bluetooth status will be displayed on the menu bar of the Mac, and the option ‘Show in Menu Bar‘ will be enabled in System Settings > Control Centre > Bluetooth. For macOS version 12.0 and below, this option can also be enabled from System Preferences > Dock & Menu > Bluetooth.

The Bluetooth menu on the status bar will be visible on macOS devices after the execution of the script

Notes:

  • Although the script enables the option to display Bluetooth status on the Mac menu bar, users retain the ability to disable this option from the device end.
  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository