Configuring MacOS 11+ menu bar icons using dotfiles
February 23, 2022Dotfiles are files that contain some configuration related to applications, tools, or your device, such as the familiar .bashrc
. Tracking these files in version control is a convenient way of sharing configuration between devices and simplifying setting up a new device. There are many tools available to make this a more manageable process, often implementing extensive functionality beyond the scope of a traditional dotfile. I personally use chezmoi. You can find my dotfiles here.
Managing MacOS configuration with dotfiles
MacOS allows a user to set system properties using defaults
. This enables you to include system configuration such as trackpad settings, Finder layout, dock style, and much, much more in your dotfiles. Whenever you apply your dotfiles on a new or outdated device, it makes sure your device behaves exactly like it did before! My configuration is largely copied from Mathias Bynens’ Sensible MacOS defaults.
Unfortunately, the identifiers used for setting system properties are subject to change, especially between major versions of MacOS. You aren’t exposed to these changes until you try to apply your dotfiles to a new device, and it can be quite a pain to figure out how to get things working again. One of these changes happened with the release of MacOS 11, or Big Sur, which introduced the control centre. This renamed some identifiers that I used, and the new names were not particularly easy to find. This blog post documents the ones that I ran into.
Battery percentage
To see the percentage of battery charge left, the identifier before MacOS 11 was
defaults write com.apple.menuextra.battery ShowPercent -string "YES"
With Big Sur or Monterey, you should instead use
defaults write com.apple.controlcenter.plist BatteryShowPercentage -bool true
Volume icon
The volume icon before MacOS 11 was enabled with
defaults write com.apple.systemuiserver menuExtras -array "/System/Library/CoreServices/Menu Extras/Volume.menu"
With Big Sur or Monterey, this is now enabled by using
defaults write com.apple.controlcenter.plist Sound -int 18
Note that this uses an -int 18
flag instead of a -bool
or -string
; this seems to be the signal to enable it, whereas -int 24
would disable it.
Bluetooth icon
To enable the Bluetooth icon in versions before MacOS 11, I used
defaults write com.apple.systemuiserver menuExtras -array "/System/Library/CoreServices/Menu Extras/Bluetooth.menu"
Similar to the volume icon, it is enabled in Big Sur or Monterey with
defaults write com.apple.controlcenter.plist Bluetooth -int 18