{"id":28962759,"url":"https://github.com/hitblast/defaults-rs","last_synced_at":"2025-06-24T03:12:01.874Z","repository":{"id":298684776,"uuid":"1000755964","full_name":"hitblast/defaults-rs","owner":"hitblast","description":"🍺  A near drop-in replacement for the macOS defaults CLI with API bindings for Rust.","archived":false,"fork":false,"pushed_at":"2025-06-23T03:28:43.000Z","size":129,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-23T04:28:09.493Z","etag":null,"topics":["cli","command-line-utilities","defaults","macos","macos-defaults","macos-preferences","rust","rust-lang"],"latest_commit_sha":null,"homepage":"https://hitblast.github.io/defaults-rs/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hitblast.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-12T09:18:56.000Z","updated_at":"2025-06-23T03:28:47.000Z","dependencies_parsed_at":"2025-06-12T10:51:28.456Z","dependency_job_id":null,"html_url":"https://github.com/hitblast/defaults-rs","commit_stats":null,"previous_names":["hitblast/defaults-rs"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/hitblast/defaults-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hitblast%2Fdefaults-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hitblast%2Fdefaults-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hitblast%2Fdefaults-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hitblast%2Fdefaults-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hitblast","download_url":"https://codeload.github.com/hitblast/defaults-rs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hitblast%2Fdefaults-rs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261416291,"owners_count":23155036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","command-line-utilities","defaults","macos","macos-defaults","macos-preferences","rust","rust-lang"],"created_at":"2025-06-24T03:12:01.371Z","updated_at":"2025-06-24T03:12:01.865Z","avatar_url":"https://github.com/hitblast.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\"assets/logo.png\" width=\"200px\"\u003e\n\n# \u003cimg src=\"https://raw.githubusercontent.com/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/rust/rust.png\" width=\"40px\"\u003e defaults-rs\n\nNear drop-in replacement for the macOS `defaults` CLI with API bindings for Rust\n\n\u003c/div\u003e\n\n\u003e [!IMPORTANT]\n\u003e Consider starring the project if you like it! It really supports and motivates me to make more projects like these.\n\n## Table of Contents\n\n- [Key Features](#key-features)\n- [Installation](#installation)\n- [CLI Usage](#cli-usage)\n- [Rust API](#rust-api)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Key Features\n\n- Use it as a **direct replacement** for `defaults` without hassle.\n- Read, write, delete, rename, import/export, and inspect preferences using the built-in **async Rust API**.\n- Supports user and global **domains**, or any plist **file path**.\n- Supports **all plist value types** (int, float, bool, string, arrays, dictionaries).\n- Pretty-prints plist data close to the original `defaults` format.\n- Handles both binary and XML plist files transparently.\n- Extensible.\n\n## Installation\n\n### Using `brew`:\n\n```sh\n$ brew install hitblast/tap/drs\n```\n\n### Using `cargo`:\n\n```sh\n$ cargo install defaults-rs\n```\n\n### Using `mise`:\n\n```sh\n# NOTE: This will compile the binary for your system.\n$ mise use -g cargo:defaults-rs\n```\n\n### Manual Build \u0026 Install\n\n```sh\n$ cargo install --git https://github.com/hitblast/defaults-rs\n```\n\n## CLI Usage\n\nThe CLI command is `drs`. It closely mimics the original `defaults` tool.\n\n### Examples\n\n#### Read a key (domain or path)\n\n```sh\n$ drs read com.apple.dock tilesize\n$ drs read ~/Library/Preferences/com.apple.dock.plist tilesize\n$ drs read ./custom.plist mykey\n$ drs read com.apple.dock.plist tilesize   # if file exists, treated as path; else as domain\n```\n\n#### Write a key\n\n```sh\n$ drs write com.apple.dock tilesize -i 48\n$ drs write com.apple.dock tilesize --int 48\n$ drs write ~/Library/Preferences/com.apple.dock.plist tilesize --int 48\n$ drs write ./custom.plist mykey --string \"hello\"\n```\n\n#### Delete a key\n\n```sh\n$ drs delete com.apple.dock tilesize\n$ drs delete ~/Library/Preferences/com.apple.dock.plist tilesize\n$ drs delete ./custom.plist mykey\n```\n\n#### Read the whole domain\n\n```sh\n$ drs read com.apple.dock\n$ drs read ~/Library/Preferences/com.apple.dock.plist\n$ drs read ./custom.plist\n```\n\n#### List all entries in all domains containing word\n\n```sh\n$ drs find \u003cword\u003e\n```\n\n#### View all domains\n\n```sh\n$ drs domains\n```\n\n#### Use the global domain\n\n```sh\n$ drs read -g com.apple.keyboard.fnState\n$ drs write -g InitialKeyRepeat --int 25\n```\n\n#### Read the type of a key\n\n```sh\n$ drs read-type com.apple.dock tilesize\n```\n\n#### Rename a key\n\n```sh\n$ drs rename com.apple.dock oldKey newKey\n$ drs rename ~/Library/Preferences/com.apple.dock.plist oldKey newKey\n$ drs rename ./custom.plist oldKey newKey\n```\n\n#### Import/export a domain\n\n```sh\n$ drs import com.apple.dock ./mysettings.plist\n$ drs export com.apple.dock ./backup.plist\n```\n\n## Rust API\n\nTo access the developer-side API for `defaults-rs`, run the following command and add it to your Cargo project:\n\n```sh\n$ cargo add defaults-rs\n```\n\nPlease refer to the [API reference](https://hitblast.github.io/defaults-rs) for more information about all the available functions.\n\n### Example\n\n```rust\nuse defaults_rs::{Domain, PrefValue, Preferences};\n\n#[tokio::main]\nasync fn main() {\n    // Read a value\n    let value = Preferences::read(Domain::User(\"com.apple.dock\".into()), Some(\"tilesize\"))\n        .await\n        .unwrap();\n\n    // Write a value\n    Preferences::write(\n        Domain::User(\"com.apple.dock\".into()),\n        \"tilesize\",\n        PrefValue::Integer(48),\n    )\n    .await\n    .unwrap();\n\n    // Delete a key\n    Preferences::delete(Domain::User(\"com.apple.dock\".into()), Some(\"tilesize\"))\n        .await\n        .unwrap();\n}\n```\n\nThe API also provides unified batch functions which can significantly reduce the amount of I/O per read/write/delete if you want to do multiple queries.\n\n```rust\nuse defaults_rs::{Domain, PrefValue, Preferences};\n\n#[tokio::main]\nasync fn main() -\u003e anyhow::Result\u003c()\u003e {\n    // Batch write (only updates designated keys)\n    let write_batch = vec![\n        (Domain::User(\"com.apple.dock\".into()), \"tilesize\".into(), PrefValue::Integer(48)),\n        (Domain::User(\"com.apple.dock\".into()), \"autohide\".into(), PrefValue::Boolean(true)),\n        (Domain::User(\"com.apple.keyboard\".into()), \"InitialKeyRepeat\".into(), PrefValue::Integer(25)),\n    ];\n    Preferences::write_batch(write_batch).await?;\n\n    // Batch read:\n    let read_batch = vec![\n        (Domain::User(\"com.apple.dock\".into()), Some(\"tilesize\".into())),\n        (Domain::User(\"com.apple.keyboard\".into()), None), // Read entire domain\n    ];\n    let results = Preferences::read_batch(read_batch).await?;\n    for (domain, key, result) in results {\n        match key {\n            None =\u003e println!(\"Domain: {:?}, Full plist: {:?}\", domain, result),\n            Some(k) =\u003e println!(\"Domain: {:?}, Key: {:?}, Value: {:?}\", domain, k, result),\n        }\n    }\n\n    // Batch delete:\n    let delete_batch = vec![\n        (Domain::User(\"com.apple.dock\".into()), Some(\"tilesize\".into())),\n        (Domain::User(\"com.apple.dock\".into()), Some(\"autohide\".into())),\n        (Domain::User(\"com.apple.keyboard\".into()), None), // Delete entire domain file\n    ];\n    Preferences::delete_batch(delete_batch).await?;\n\n    Ok(())\n}\n```\n\n## Contributing\n\nNew pull requests and issues are always welcome. Please read the [contribution guidelines](./CONTRIBUTING.md) for more information about certain parts of the codebase and/or how to form a structured pull request.\n\n## License\n\nThis project has been licensed under the [MIT License](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhitblast%2Fdefaults-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhitblast%2Fdefaults-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhitblast%2Fdefaults-rs/lists"}