|
1 | | -# user-defaults |
2 | | -Wrapper for macOS defaults |
| 1 | +# macOS User Defaults (`user-defaults`) |
| 2 | +Wrapper for macOS defaults, designed for running with admin privileges to read/write the defaults of another user. |
| 3 | + |
| 4 | +## Usage |
| 5 | + |
| 6 | +Usage remains the same as the native macOS defaults command, with the following additional flags: |
| 7 | + |
| 8 | +| Flag | Description | |
| 9 | +|------------|------------------------------------------------------------------------------------------------------| |
| 10 | +| `-user` | The user to read/write the preferences with. | |
| 11 | +| `-quiet` | Does not show error output or confirmations. In the case of a read command, only the value is shown. | |
| 12 | +| `-force` | When writing, will ignore the existence of a Managed Preference and write the value anyway. | |
| 13 | +| `-version` | Displays the version | |
| 14 | + |
| 15 | +When using the `-user` flag, written preferences are stored in the user's library unless the domain specified is an absolute path. |
| 16 | + |
| 17 | +## Additional Conveniences |
| 18 | + |
| 19 | +* If writing, the user's defaults are automatically reloaded. This ensures the following: |
| 20 | + * The change is effective immediately. |
| 21 | + * The System Settings (or System Preferences) shows the updated value. |
| 22 | +* If writing, warns about attempting to modify Managed Preferences and aborts unless `--force` flag is used |
| 23 | +* Any boolean-like value is automatically saved as a boolean, unless a different type is specified. |
| 24 | + * Includes: `YES|Yes|yes|NO|No|no|TRUE|True|true|FALSE|False|false|1|0` |
| 25 | +* A domain of `.GlobalPreferences` is automatically changed to `-g` for compatibility. |
| 26 | + |
| 27 | +## Optional Installer Script |
| 28 | +If your script is running as root, you can silently install the library using the 1-liner below: |
| 29 | + |
| 30 | +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/jonesiscoding/user-defaults/HEAD/bin/install.sh)" || exit 1 |
| 31 | +The installer will check this repo for the most recent release, then if needed, download & install to `/usr/local/sbin/user-defaults`. |
0 commit comments