Closed rmgpinto closed 6 months ago
The first three can be set like so:
system.defaults = {
CustomUserPreferences = {
"~/Library/Preferences/ByHost/com.apple.controlcenter.plist" = {
"Bluetooth" = 18;
"Sound" = 16;
"BatteryShowPercentage" = 1;
};
};
};
I'm not sure how to get nix-darwin to use the currentHost
flag, so I don't know how to set the Spotlight setting. The closest I can get is:
system.defaults = {
CustomSystemPreferences = {
"com.apple.Spotlight" = {
"MenuItemHidden" = 1;
};
};
};
which produces this command:
defaults write com.apple.Spotlight 'MenuItemHidden' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer>1</integer>
</plist>'
which is equivalent to defaults write com.apple.Spotlight MenuItemHidden -int 1
Ah, okay. nix-darwin doesn't support the -currentHost
flag (although home-manager does). However, in practice it seems that you can replicate this option by using a path in ~/Library/Preferences/ByHost
(as you did for Control Center). Thus:
system.defaults = {
CustomUserPreferences = {
"~/Library/Preferences/ByHost/com.apple.controlcenter.plist" = {
"Bluetooth" = 18;
"Sound" = 16;
"BatteryShowPercentage" = 1;
};
"~/Library/Preferences/ByHost/com.apple.Spotlight.plist" = {
"MenuItemHidden" = 1;
};
};
};
should do exactly what you want
thanks @Samasaur1
Is there a way to define those CustomUserPreferences
in a separate block, example:
system.defaults = {
CustomUserPreferences = {
"~/Library/Preferences/ByHost/com.apple.controlcenter.plist" = {
"Bluetooth" = 18;
"BatteryShowPercentage" = 1;
};
};
// more attributes...
CustomUserPreferences = {
"~/Library/Preferences/ByHost/com.apple.controlcenter.plist" = {
"Sound" = 16;
};
};
};
the last block is overriding the first one.
huh, that's weird, I don't think it's supposed to do that. Regardless, you should be able to set the key directly, which will hopefully get around the issue
system.defaults.CustomUserPreferences."~/Library/Preferences/ByHost/com.apple.controlcenter.plist"."Sound" = 16;
Is there a way I could achive the settings below?
Thanks