What the meaning of `defaults write...` on macOS?

448 阅读1分钟

In the AnkiConnect readme page, there is a caveat:

Starting with Mac OS X Mavericks, a feature named App Nap has been introduced to the operating system. This feature causes certain applications which are open (but not visible) to be placed in a suspended state. As this behavior causes AnkiConnect to stop working while you have another window in the foreground, App Nap should be disabled for Anki:
Start the Terminal application.
Execute the following commands in the terminal window:

defaults write net.ankiweb.dtop NSAppSleepDisabled -bool true
defaults write net.ichi2.anki NSAppSleepDisabled -bool true
defaults write org.qt-project.Qt.QtWebEngineCore NSAppSleepDisabled -bool true

What the meaning of defaults write...?

defaults is a command line utility that manipulates plist files. ~/Library/Preferences is for the user configuration and /Library/Preferences is for the system configuration. defaults accesses the plists based on the domain given.

As AnkiConnect is a Anki add-on which is not the system level software, so defaults write net.ankiweb.dtop NSAppSleepDisabled -bool true means to set the value of NSAppSleepDisabled key in the ~/Library/Preferences/net.ankiweb.dtop.plist file to 1.