Module up_rs::tasks::defaults

source ·
Expand description

Update macOS defaults.

Make it easy for users to provide a list of defaults to update, and run all the updates at once. Also takes care of restarting any tools to pick up the config, or notifying the user if they need to log out or reboot.

Note that manually editing .plist files on macOS (rather than using e.g. the defaults binary) may cause changes not to be picked up until cfprefsd is restarted (more information).

Work around this by restarting your machine or running sudo killall cfprefsd after changing defaults.

§Specifying preference domains

For normal preference domains, you can directly specify the domain as a key, so to set defaults read NSGlobalDomain com.apple.swipescrolldirection you would use:

run_lib: defaults
data:
  NSGlobalDomain:
    com.apple.swipescrolldirection: false

You can also use a full path to a plist file (the .plist file extension is optional, as with the defaults command).

§Current Host modifications

To modify defaults for the current host, you will need to add a custom entry for the path, using the UP_HARDWARE_UUID environment variable to get the current host.

e.g. to set the preference returned by defaults -currentHost read -globalDomain com.apple.mouse.tapBehavior you would have:

run_lib: defaults
data:
  ~/Library/Preferences/ByHost/.GlobalPreferences.${UP_HARDWARE_UUID}.plist:
      # Enable Tap to Click for the current user.
      com.apple.mouse.tapBehavior: 1

§Root-owned Defaults

To write to files owned by root, set the needs_sudo: true environment variable, and use the full path to the preferences file.

run_lib: defaults
needs_sudo: true
data:
  # System Preferences -> Users & Groups -> Login Options -> Show Input menu in login window
  /Library/Preferences/com.apple.loginwindow:
    showInputMenu: true

  # System Preferences -> Software Update -> Automatically keep my mac up to date
  /Library/Preferences/com.apple.SoftwareUpdate:
    AutomaticDownload: true

Structs§

Enums§