On Jul 9, 2020, at 3:41 AM, Gabriel Zachmann via Cocoa-dev 
<cocoa-dev@lists.apple.com> wrote:
> 
> I am confused about the way system preferences are organized (or preferences 
> in general).
> 
> I read the man page of defaults(1), but it is still unclear to me what happens
> when I do, for instance,
> 
>  defaults -currentHost read com.apple.screensaver idleTime
> 
> as opposed to 
> 
>  defaults read com.apple.screensaver idleTime
> 
> I get different results in the two cases.
> Yet, the System Preferences GUI shows me only the value I get from 
> "currentHost",
> and that is also the idle time after which the screensaver on my laptop gets 
> launched by macOS,
> so it seems to be he only value I should care about.
> 
> So, what is the significance of the value of the version without 
> "currentHost" ?
> When is it important?

Basically, it's not important.  Something or someone erroneously set that 
preference in a non-host-specific domain, but nothing uses that 
non-host-specific value.  (For example, somebody may have issued the command 
"defaults write com.apple.screensaver idleTime -int 5", unwittingly leaving out 
"-currentHost".)

It would be used as a fallback if there were no host-specific setting, as part 
of the normal search path.  However, it's not normally set in a 
non-host-specific domain, at all.


In general, preferences are organized in a hierarchy of domains, from most 
specific to least specific.

1

Current User

Current Application

Current Host

2

Current User

Current Application

Any Host

3

Current User

Any Application

Current Host

4

Current User

Any Application

Any Host

5

Any User

Current Application

Current Host

6

Any User

Current Application

Any Host

7

Any User

Any Application

Current Host

8

Any User

Any Application

Any Host


In most cases, an app will set a preference in the Current User, Current 
Application, Any Host domain.  Generally, an app will search for a preference 
in the domains in the order listed, using the first one it finds.  (The APIs do 
the searching for the app.  The app simply doesn't override that standard 
behavior most of the time.)

However, in certain situations, it makes more sense for the app to set the 
preference for the Current Host, not Any Host.  For example, consider a 
network-mounted home folder that a user may use from a variety of different 
Macs.  Because different Macs may have different power constraints (battery vs. 
plugged in) or privacy concerns (public vs. private), they may want the screen 
saver to kick in after different intervals on different hosts.  So, the screen 
saver idle time is stored per-host.  That choice is entirely up to the software 
which stores the preference value, usually the Desktop & Screen Saver pane of 
System Preferences.

There's nothing preventing other code from setting the value in other domains 
(except that it requires admin privileges to set a preference for Any User).  
Whether that value gets used in actuality depends on the search path and the 
presence or absence of values set earlier in the search.

Regards,
Ken

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to