Sub topic 11
Tuning behavior in System Settings and with defaults
This chapter shows where macOS keeps the options that control Mission Control and Spaces, and how to read, change and undo them from the terminal. It assumes you can open System Settings, use Terminal, and already know how Spaces and Mission Control behave from the earlier chapters. You do not need shell scripting experience beyond running single commands.
Where the settings live
Most of the behavior you have seen so far is controlled from one pane: System Settings > Desktop & Dock. Scroll to the Mission Control section. The options that matter most for Spaces are:
- Automatically rearrange Spaces based on most recent use. When this is on, macOS moves the Space you used most recently toward the front of the list. Your Space numbers can change without warning.
- When switching to an application, switch to a Space with open windows for the application. Clicking an app in the Dock or pressing Command-Tab jumps to a Space that already holds one of its windows.
- Group windows by application. Mission Control stacks an app's windows together instead of spreading them out.
- Displays have separate Spaces. Each monitor gets its own set of Spaces. Changing this requires logging out and back in.
The same pane has a Keyboard Shortcuts… button for Mission Control, Application windows, Show Desktop, and the "Move left/right a space" shortcuts. It also has a Hot Corners… button, which can trigger Mission Control, Application Windows, or Desktop when the pointer hits a screen corner.
The Windows section of the same pane holds the tiling options, such as dragging windows to screen edges to tile them. Stage Manager has its own switch in the same pane. The chapters on tiling and Stage Manager cover those in detail.
How a setting becomes behavior
Each toggle writes a value into a preferences file. The Dock process reads that file and applies it. Mission Control and Spaces are handled by the Dock, not by a separate app, which is why the terminal commands in this chapter target the Dock's preference domain, com.apple.dock.
This explains two things you will see in practice. First, a toggle in System Settings and a defaults write command affect the same stored value, so the two stay in sync. Second, a value written from the terminal may not take effect until the Dock reloads, which is why killall Dock appears after each write below.
The defaults command
defaults is a built-in command-line tool for reading and writing preference values. It works with three pieces of information: a domain (here com.apple.dock), a key (here mru-spaces), and a value with a type (here a boolean, true or false).
The commands you will use most:
defaults read DOMAIN KEYprints one value.defaults read-type DOMAIN KEYprints the stored type.defaults write DOMAIN KEY -TYPE VALUEstores a value. Common type flags are-bool,-int,-floatand-string.defaults delete DOMAIN KEYremoves your override so the system default applies again.
Worked example: stop Spaces from reordering
The key mru-spaces is the stored form of "Automatically rearrange Spaces based on most recent use". Start by reading the current state:
defaults read com.apple.dock mru-spacesThere are two normal outcomes:
1means rearranging is on.0means rearranging is off.- An error such as
The domain/default pair of (com.apple.dock, mru-spaces) does not existmeans the setting was never changed, so the system default applies. The default is that Spaces are rearranged, so treat a missing key as "on". The command exits with a non-zero status in this case.
defaults prints booleans as 1 and 0, even though you write them as true and false.
Now turn the behavior off and restart the Dock:
defaults write com.apple.dock mru-spaces -bool false
killall DockThis is equivalent to switching off the toggle in System Settings. The Dock restarts on its own within a second or two. Your screen may flicker briefly, and the Dock, Mission Control and Spaces behavior are reloaded. Your windows and apps keep running.
Read the value again to confirm it:
defaults read com.apple.dock mru-spacesIt should now print 0. Open System Settings > Desktop & Dock and check that the toggle matches. If the pane was already open before you ran the command, close and reopen it, because it may show the old value.
Undoing a change
Prefer deleting your override to writing true. Deleting returns the key to its absent state, so the system can change its default in a future macOS release and you will follow it.
defaults delete com.apple.dock mru-spaces
killall DockAfter this, defaults read com.apple.dock mru-spaces shows the "does not exist" error again. That is the expected result and not a failure.
Opening Mission Control from the terminal
When a keyboard shortcut or gesture does not respond, you can test whether Mission Control itself works by launching it directly:
open -a "Mission Control"If the app opens, Mission Control is healthy and the problem is in the shortcut or gesture settings. Check the shortcut assignments under Keyboard Shortcuts, and check that the gesture is enabled under System Settings > Trackpad > More Gestures. If the app does not open, restarting the Dock with killall Dock is the next step.
This command is also useful in scripts and in automation tools that can run a shell command, since it gives a single, shortcut-independent entry point.
Other Dock keys you may meet
Several other options in the Mission Control section are stored under com.apple.dock in the same way. You can read them the same way you read mru-spaces. These are the ones most often used:
| Setting in System Settings | Key | Type | Notes |
|---|---|---|---|
| Automatically rearrange Spaces based on most recent use | `mru-spaces` | boolean | Missing key means on. |
| Switch to a Space with open windows for the application | `workspaces-auto-swoosh` | boolean | Missing key means on. |
| Group windows by application | `expose-group-apps` | boolean | Missing key means off. |
| Displays have separate Spaces | `spans-displays` | boolean | Inverted: `true` means displays share one Space. Needs logout. |
Two cautions apply to this table. The spans-displays key is inverted compared with its toggle, so true means the toggle is off. A change to it takes effect only after you log out and back in, so killall Dock is not enough. Also, these key names are not part of a documented, supported interface. Apple can rename or ignore them in a later macOS release, so confirm each one with defaults read and check the result in System Settings before you depend on it in a script.
Common errors
These are the problems that come up most often with this workflow.
- Forgetting
killall Dock. The value is stored, but the running Dock still uses the old one. System Settings may even show the new value while the behavior does not change. - Writing the wrong type.
defaults write com.apple.dock mru-spaces -string falsestores text, not a boolean. Use-bool falsefor toggles.defaults read-typeshows what was stored. - Treating a missing key as an error. A key that has never been changed does not exist. That means "use the default".
- Wrong domain.
com.apple.dockis correct for these options. A typo creates a brand-new domain that nothing reads, anddefaultswill not warn you. - Expecting immediate effect for a display change. The
spans-displayssetting needs a logout. - Mixing methods. If you change a toggle in System Settings and also have a script that rewrites the same key at login, the script wins on the next login. Keep one source of truth.
Settings that are not in defaults
Some behavior has no simple Dock key, or is easier to manage elsewhere:
- Space switching animation. The slide between Spaces follows the accessibility option Reduce motion, found under System Settings > Accessibility > Display. Turning it on replaces the slide with a fade.
- Per-app Space assignment. Use the Dock, as described in the app assignment chapter. Control-click the app icon, choose Options, then Assign To. Doing this in the interface is safer than editing the stored data directly.
- Shortcuts. Mission Control and Space shortcuts are edited in the Keyboard Shortcuts panel. Remapping them by script is fragile, because the stored format is complicated.
As a rule, use defaults for simple on/off Dock options, and use System Settings for anything that has a structured list of values.
Exercise
You run defaults write com.apple.dock mru-spaces -bool false. System Settings shows the toggle as off, but your Spaces still reorder as you switch between them. What is the most likely cause and the fix? Then explain how you would return to the system default afterward.
Show answer
The Dock has not reloaded, so it is still using the old value. Run killall Dock to restart it, then test again. If it still reorders, confirm the stored value with defaults read com.apple.dock mru-spaces (it should print 0). To return to the system default, run defaults delete com.apple.dock mru-spaces followed by killall Dock. A later defaults read will then report that the key does not exist, which is expected.
Exercise
A colleague's script runs defaults read com.apple.dock expose-group-apps and the command prints an error saying the domain/default pair does not exist. Is the script broken, and what should it assume about the setting?
Show answer
The script is not broken. The error means nobody has changed the setting, so the key was never written. The script should treat the missing key as the system default, which for grouping windows by application is off. A robust script checks the exit status of defaults read and falls back to the default value when the key is missing.