| Crates.io | defaults-rs |
| lib.rs | defaults-rs |
| version | 1.2.2 |
| created_at | 2025-06-12 10:43:46.702902+00 |
| updated_at | 2025-12-21 21:02:40.195207+00 |
| description | Open-source interface to a user's defaults on macOS |
| homepage | |
| repository | https://github.com/machlit/defaults-rs |
| max_upload_size | |
| id | 1709677 |
| size | 7,350,029 |
defaults tool.brew:$ brew install hitblast/tap/drs
cargo:$ cargo install defaults-rs
mise:# NOTE: This will compile the binary for your system.
$ mise use -g cargo:defaults-rs
The CLI command is drs. It closely mimics the original defaults tool.
$ drs read com.apple.dock tilesize
$ drs read ~/Library/Preferences/com.apple.dock.plist tilesize
$ drs read com.apple.dock.plist tilesize # this also works!
$ drs write com.apple.dock tilesize -i 48
$ drs write com.apple.dock tilesize --int 48
$ drs write ~/Library/Preferences/com.apple.dock.plist tilesize --int 48
# create a new domain (disables checks)
$ drs write rubberduck --force duckcount --int 5
$ drs delete com.apple.dock tilesize
$ drs delete ~/Library/Preferences/com.apple.dock.plist tilesize
$ drs read com.apple.dock
$ drs read ~/Library/Preferences/com.apple.dock.plist
$ drs find <word>
$ drs domains
# disable fuzzy-searching with the -n/--no-fuzzy flag
$ drs domains -n
$ drs read -g com.apple.keyboard.fnState
$ drs write -g InitialKeyRepeat --int 25
$ drs read-type com.apple.dock tilesize
$ drs rename com.apple.dock oldKey newKey
$ drs rename ~/Library/Preferences/com.apple.dock.plist oldKey newKey
$ drs import com.apple.dock ./mysettings.plist
$ drs export com.apple.dock ./backup.plist
In order to use the Rust API for defaults-rs, run this command in your project directory:
$ cargo add defaults-rs --no-default-features
Check out the official docs.rs API reference for defaults-rs here.
For examples, check out: examples/
defaults-rs was initially made with the necessity of a thin wrapper around the CoreFoundation APIs which are responsible for storing a user's defaults. Now, it also serves as a backend for directly interfering with system preferences in the cutler project.
Some temporary limitations include:
.plist files for applications (Info.plist specifically) cannot be read by this tool as of now, although this is planned for the next release.And since this is a completely open-source attempt to replicate the capabilities of defaults (which is a proprietary software), there will be certain limitations:
com.apple.Safari). defaults-rs attempts to read in the Current User + Any Host space for the maximum achievable domain index. This is not a threat to I/O operations so it's not really much of a caveat.New pull requests and issues are always welcome. Please read the contribution guidelines for more information about certain parts of the codebase and/or how to form a structured pull request.
This project has been licensed under the MIT License.