Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply-user-defaults should handle array values #1

Open
msanders opened this issue Jan 5, 2020 · 3 comments
Open

apply-user-defaults should handle array values #1

msanders opened this issue Jan 5, 2020 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@msanders
Copy link
Contributor

msanders commented Jan 5, 2020

Cider storage of defaults and applying defaults doesn't appear to support arrays.

Example usage:
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'

My intention is to be able to save new persistent applications into the Dock.
Since my common usage of Cider is when installing new macOS versions which keep changing the default value of com.apple.dock persistent-apps, I don't want cider apply-defaults to erase the entire persistent-apps value.

Issue reported by @RogerThiede, migrated from msanders/cider#51.

@msanders
Copy link
Contributor Author

msanders commented Jan 5, 2020

@RogerThiede this is an interesting feature, although I'm not sure how -array-add would be represented in YAML (-array and -dict should be pretty straightforward). For managing dock items, I currently use dockutil as shown here:

brew install dockutil
dockutil --remove all --no-restart
dockutil --add /Applications/Firefox.app --no-restart
dockutil --add /Applications/Emacs.app --no-restart
dockutil --add /Applications/Utilities/Terminal.app --no-restart
dockutil --add ~/Downloads --display stack # Implicitly restarts the Dock.

@msanders msanders added enhancement New feature or request help wanted Extra attention is needed labels Jan 6, 2020
@RogerThiede
Copy link

RogerThiede commented Jan 7, 2020 via email

@pdrastil
Copy link

pdrastil commented Feb 2, 2021

I would really appreciate the possibility to set array values as well, but only via -array flag to preserve immutability. For appending values you could use anchors that are supported in YAML syntax, however merge behaviour would be strongly preferred.

YAML sample:

com.binarynights.ForkLift-3:
  FileEditors: &editors
  - *editors
  - ApplicationPath: "/Applications/Visual Studio Code.app"
     Default: 1
     Extensions: ''

EDIT: You might have to check correct syntax and supported options of the YAML parser. Anchors are advanced feature and they are not always supported or they might have implementation differences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants