Skip to content

Commit 6114954

Browse files
cursoragentpablo
andcommitted
Add XML support for macOS defaults export and import
Co-authored-by: pablo <pablo@maze.design>
1 parent da9a3bc commit 6114954

File tree

2 files changed

+383
-8
lines changed

2 files changed

+383
-8
lines changed

README.md

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ dot --postinstall # Run only postinstall hooks
222222
dot --postlink # Run only postlink hooks
223223

224224
# macOS defaults management
225-
dot --defaults-export # Export current settings to plist files
226-
dot --defaults-import # Import settings from plist files
225+
dot --defaults-export # Export current settings to plist/XML files
226+
dot --defaults-import # Import settings from plist/XML files
227227

228228
# Upgrade dot itself
229229
dot --upgrade
@@ -319,21 +319,54 @@ This is useful for:
319319

320320
## macOS Defaults
321321

322-
Manage macOS system preferences with plist files:
322+
Manage macOS system preferences with plist or XML files:
323323

324324
```yaml
325325
profiles:
326326
"*":
327327
dock:
328328
defaults:
329329
"com.apple.dock": "macos/dock.plist"
330-
"com.apple.finder": "macos/finder.plist"
330+
"com.apple.finder": "macos/finder.xml" # XML format for better readability
331+
"com.apple.safari": "macos/safari.plist" # Binary plist format
331332
```
332333

333-
Commands:
334-
- `dot --defaults-export`: Export current settings to plist files
335-
- `dot --defaults-import`: Import settings from plist files
336-
- Normal runs will warn if current settings differ from plist files
334+
### File Format Support
335+
336+
- **Binary plist** (`.plist`): Standard macOS binary format, compact but not human-readable
337+
- **XML format** (`.xml`): Human-readable XML format, ideal for version control and manual editing
338+
339+
The tool automatically detects the target file format based on the file extension:
340+
- Files ending in `.xml` (case-insensitive) are exported as XML using `plutil` conversion
341+
- All other files are exported as binary plist format
342+
343+
### Commands
344+
345+
- `dot --defaults-export`: Export current settings to plist/XML files
346+
- `dot --defaults-import`: Import settings from plist/XML files
347+
- Normal runs will warn if current settings differ from saved files
348+
349+
### Benefits of XML Format
350+
351+
- **Human-readable**: Easy to view and edit manually
352+
- **Version control friendly**: Git diffs show meaningful changes
353+
- **Cross-platform compatible**: Can be viewed on any system
354+
- **Debugging**: Easier to troubleshoot configuration issues
355+
356+
### Example XML Output
357+
358+
```xml
359+
<?xml version="1.0" encoding="UTF-8"?>
360+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
361+
<plist version="1.0">
362+
<dict>
363+
<key>autohide</key>
364+
<true/>
365+
<key>tilesize</key>
366+
<integer>36</integer>
367+
</dict>
368+
</plist>
369+
```
337370

338371
## State Management
339372

0 commit comments

Comments
 (0)