In this article we will go over .plist files, defaults command and some software to work with plist files.
All of the Macs preferences are stored in plist files (property list file). Some settings are not accessible from the GUI of the MacOS or its applications preferences menus. You might also want to configure an application before a user launched it on a new Mac he just got : For example, you might want to set the default home page for a browser, adjust the screen to lock after three and a half minutes or set the VPN configuration.
Every time you make a change to a setting via any menu, those changes are reflected in the relevant plist file by updating an entry and setting a value on that entry in the relevant plist file. It looks like an XML file, but if you try to open it, you will not be able to read it with a text editor as it is a binary file. You need a program to interact with those files. This is where the defaults command comes in.
We can take a look at the many .plist files located at:
Preview plist files
MacOS has a nice feature that allows preview to display the content of a plist file that is readable. Once you select the file you want to view, hit space, and the content will be displayed.
Quick edit plist files
When you are using the defaults command you need to specify if you want to read a plist or update it.
defaults read com.apple.finder
View only the value of AppleShowAllFiles. The result can be TRUE, FALSE, YES or NO.
defaults read com.apple.finder.plist AppleShowAllFiles
Let’s change the value so that we can see all files and verify it was changed.
defaults write com.apple.finder.plist AppleShowAllFiles YES
Converting plist files to text
You might need to convert the plist file into something more human readable. Use the plutil command to convert plist to txt. I use this when I need to take the content of a plist file and paste its content to JAMF to deploy it. Make a copy of the file you will be converting and…
plutil -convert xml1 com.apple.finder.plist
You can reverse the conversion using:
plutil -convert binary1 com.my.app.plist
Applying what we learned + some useful apps.
You would like to change the homepage for all your Macs in the Chrome browser to your company portal.
- The first thing to decide on is this a user or a computer policy and how will you be deploying it
- Now you need to know where is the file that you need to edit. This can be done by Googling the file to update and then using the defaults command.
- You can also look at the file system changes when you are making that change on a virtual MacOS. I love an app called http://fsmonitor.com/. It gives you this nice tree look of the live updates to the OS.
- Another super great tool is Pref Setter. It will show you a list of all the plist found on the Mac and gives you an option to update from inside the app. I would not recommend using it to update, it’s quite old, but it is great to get a general view.
- PlistEdit Pro is my tool of choice for editing. It gives a great visualization and simplifies editing. There is also a more affordable alternative here.
- There is also a tool that is provided by Apple called plistbuddy.. I have not used it yet but heard it mentioned several times on the MacAdmins podcast.
Adding default settings to packages
Let’s say that that you are building a package with JAMF composer and you need to add some default setting for that app. Once you add the app and use a post-install script to run the defaults command with the values you want. Make sure to build a .pkg file though if you want it to work correctly.
Well, that’s it for now guys. While doing some research for this article, I found a book by Armin Briegel (https://scriptingosx.com) . His book Property Lists, Preferences and Profiles for Apple Administrators is only available with a US Apple ID. Perhaps future books will be as he mentioned on his blog post.