Occasionally I have a need to disable a System Preference pane on a machine. For example for a lab machine or public shared machine. You can accomplish this by using a configuration profile, which I’ve used in the past. Often times it was originally created by someone else, which means I can’t really edit it or make changes on the fly.
So I wrote Panes. A small Ruby Gem that helps me disable system preference panes. The intent is to run the commands as a postinstall script … either on the end of a DeployStudio workflow or in a payload free package.
Here’s how it works.
Install panes:
sudo gem install panes
verify panes installed:
gem list
Panes Usage
You must require panes in your ruby script, before you call it.
require 'panes'
To list the available system preference panes (though not all maybe available for your hardware):
puts Panes.List
That should display a list like this:
Accounts.prefPane Appearance.prefPane AppStore.prefPane Bluetooth.prefPane DateAndTime.prefPane DesktopScreenEffectsPref.prefPane DigiHubDiscs.prefPane Displays.prefPane Dock.prefPane EnergySaver.prefPane Expose.prefPane Extensions.prefPane FibreChannel.prefPane iCloudPref.prefPane ......
Panes disables preferences by using the CFBundleIdentifier. To list the available CFBundleIdentifier’s:
puts Panes.CFBundleIdentifier
Output will look like this:
com.apple.preferences.users com.apple.preference.general com.apple.preferences.appstore com.apple.preferences.Bluetooth com.apple.preference.datetime com.apple.preference.desktopscreeneffect com.apple.preference.digihub.discs com.apple.preference.displays ....
Once you have the CFBundleIdentifier you want you can disable the pane. Let’s disable the Sharing pane. Here’s the before.
To disable “Sharing”:
Panes.Disable("com.apple.preferences.sharing")
After:
To disable multiple panes at once:
Panes.Disable( "com.apple.preference.dock", "com.apple.preference.energysaver", "com.apple.preference.network")
results:
What if you decide later that you need to enable a pane?
To enable one pane:
Panes.Enable("com.apple.preference.network")
or to rest and enable all panes:
Panes.Reset
Everything goes back to normal.
For more documentation check out my GitHub or Ruby Gems.