Is there a way to toggle the check boxes (enable or disable the services) in the System Preferences > iCloud preference pane via command line or Bash?
Since I couldn't find any
defaults write-like command line solution, I'd suggest using Applescript and UI scripting.
In the following example, you activate "System preferences">"iCloud" and then define that the "Back To My Mac" feature is the checkbox in row 11 (where "iCloud Drive" would be row 1). Then you can simply tell the checkbox to turn on/off, or (as shown below) always turn on if it's currently off (
value of checkbox is a boolean, thus can be directly used in an
You can simply save this script and execute it on the command line via
It is important to note that I did not try every checkbox and further UI scripting may be necessary, e.g. where further options can be toggled or passwords are requested.
tell application "System Preferences" to set current pane to pane "iCloud" tell application "System Events" tell window "iCloud" of process "System Preferences" set btmmBox to checkbox 1 of UI element 1 of row 11 of table 1 of scroll area 1 of group 1 tell btmmBox if not (its value as boolean) then click btmmBox end tell --get value of btmmBox end tell end tell