1

I am currently playing around with using defaults to change certain settings on my Mac (MacBook Pro 13-inch, 2019). I was trying to change the setting System Preferences > Dock > Prefer tabs when opening documents. After a bit of digging I found out that I can do this with the following command:

defaults write NSGlobalDomain AppleWindowTabbingMode -string '<always|manual|fullscreen>'

I was doing this so I could call it in a function I was writing before opening up a file in a particular application so the function always preferred opening in a new tab rather than a new window.

Note: that when I set the setting to Always in System Preference, opening a file with said application using open <file> -a <application> does indeed open the file in a new tab rather than a new window.

When testing, I went in to System Preferences and set the setting to Manually. Thereupon, I quit System Preferences and ran the following commands:

$ defaults read NSGlobalDomain AppleWindowTabbingMode
manual
$ defaults write NSGlobalDomain AppleWindowTabbingMode -string 'always'
$ defaults read NSGlobalDomain AppleWindowTabbingMode
always
$ open <file> -a <application>

When I run this, the file opens in a new window and not a new tab. In fact, it only opens in a new tab once I reopen System Preferences and open the Dock pane (running open <file> -a <application> opens in a new file now`).

It seems to me that Apple is overriding me in a sense but I can't figure out how to make this work. It seems odd that I need to manually interact with System Preferences (doesn't need to be the setting itself directly, but its pane) to get the effects of the setting change to take hold. Also, I found that if System Preferences is open while I am doing it, I need to quit System Preferences then navigate to the Dock pane for it to take effect.

Is there anyway to get around this? What is actually happening here that is preventing the effects of the settings change from taking hold?

Noah Wilder
  • 1,656
  • 20
  • 38
  • Many programs (/system components/etc) read their settings when they start up; if you change their settings while they're running, they won't *notice* that the settings got changed unless they're somehow notified of the change. How this is done depends entirely on the program in question. – Gordon Davisson Jan 24 '20 at 06:17
  • @GordonDavisson, why is this happening then even after I quit System Preferences? – Noah Wilder Jan 24 '20 at 13:44
  • It's not System Preferences that needs to update its state, it's the system program (e.g. the Dock process). When you make a change in System Preferences, it'll both change the setting and notify the Dock to load the new setting. Apparently if you run System Preferences and load the Dock pane, it'll just auto-notify the actual Dock, and thus get it to pick up your settings. – Gordon Davisson Jan 26 '20 at 02:57
  • @GordonDavisson, is there any way I can manually notify a system program (e.g. the Dock process) that the state has changed from the command line? – Noah Wilder Jan 29 '20 at 20:00

0 Answers0