Sub topic 11
Tuning behavior in System Settings and with defaults
This chapter assumes you know how Spaces and Mission Control work, and that you are comfortable with System Settings and running commands in Terminal. It covers where the main options live and how to change one of them with the defaults command.
Where the settings live
Most Spaces and Mission Control behavior is controlled in System Settings under Desktop & Dock, in the Mission Control section. The options that matter most here are:
- Automatically rearrange Spaces based on most recent use. When on, macOS reorders your Spaces so the one you used last comes first.
- When switching to an application, switch to a Space with open windows for the application. When on, clicking an app in the Dock or pressing Command-Tab jumps to the Space where that app already has a window.
- Group windows by application. When on, Mission Control stacks an app's windows together.
- Displays have separate Spaces. When on, each display has its own set of Spaces. Changing it requires logging out and back in.
Keyboard shortcuts for switching Spaces are under Keyboard > Keyboard Shortcuts > Mission Control.
Why you might use defaults
The defaults command reads and writes preference files from Terminal. Most settings are easier to change in System Settings. The terminal route helps in three cases:
- You want to script a setup for several Macs.
- You want to check a value without opening the interface.
- A setting is out of sync, and you want to see what is stored.
Settings for Mission Control and Spaces are stored in the Dock's preference domain, com.apple.dock. The Dock process reads these values at startup, so a change usually takes effect only after the Dock restarts.
Worked example: stop Spaces from reordering
Many people find that Spaces moving around breaks their muscle memory. For example, Control-2 stops meaning "my browser Space". The setting behind this is mru-spaces, where "mru" means "most recently used".
First, read the current value:
defaults read com.apple.dock mru-spacesIf the output is 1, reordering is on. If you see an error saying the key does not exist, the setting was never changed and the system default applies. The default is on.
Now turn reordering off and restart the Dock:
defaults write com.apple.dock mru-spaces -bool false
killall Dockkillall Dock does not harm anything. macOS restarts the Dock automatically within a second or two. Your Spaces and windows stay where they are.
To go back to the system default, delete the override:
defaults delete com.apple.dock mru-spaces
killall DockDeleting the key is cleaner than writing true. It leaves no stored value, so a future macOS default change applies to you as well.
If a shortcut seems to do nothing, you can confirm that Mission Control itself responds:
open -a "Mission Control"Keeping the two in sync
System Settings and defaults edit the same stored values. After a terminal change, reopen the Mission Control pane to confirm that the checkbox matches.
Common errors
- Forgetting
killall Dock. The value is saved but nothing changes until the Dock restarts. - Wrong type flag.
-bool falsestores a true Boolean. Writing the stringfalsewithout the flag stores text, which the Dock may ignore. - Typing the key wrong.
defaults writeaccepts any key name, so a typo creates a harmless but useless entry. Read the key back to check it. - Expecting a key to always exist. A missing key means the default is in use. That is not an error in your setup.
Exercise
You ran defaults write com.apple.dock mru-spaces -bool false, but your Spaces still reorder. What did you probably forget, and how do you later return to the system default?
Show answer
You probably did not restart the Dock with killall Dock, so it never reread the preference. To return to the default, run defaults delete com.apple.dock mru-spaces followed by killall Dock.
Exercise
defaults read com.apple.dock mru-spaces prints an error saying the key does not exist. Does this mean Spaces reordering is broken?
Show answer
No. The key is absent when the setting was never changed, so the system default (reordering on) applies.