Apple Script for system preferences

Discussion in 'Mac Programming' started by Monaj, Aug 9, 2010.

  1. Monaj macrumors regular

    May 24, 2009
    Hi all,

    In our college we all share the iMacs with same user account, say- Anonymous. So when some other user comes and uses my system, he/she generally changes some of the properties in system preferences. It always wastes some of my precious time when I restore its setting according to mine.

    So, I am thinking -
    Thanks in advance for any help, suggestion or useful link!

  2. chown33 macrumors 604

    Aug 9, 2009
    Which settings did you want to change? Be specific.

    Most settings for a user can be read or written using the 'defaults' command in Terminal. Since Terminal accepts pasted-in commands, you could keep a simple text file on a USB thumb drive, and paste its contents into a Terminal window to set the settings the way you want.

    Some settings are not accessible through 'defaults'. Some use other commands, like 'scutil'. Some require admin privilege, but there is a command for that.
  3. Monaj thread starter macrumors regular

    May 24, 2009
    Specific Requirements

    thanks, for your reply!

    Specifically I want to perform these tasks:

    Mouse Preference-
    Expose & Spaces > Spaces Preference-
    Can you suggest me how to achieve my requirements?


  4. chown33 macrumors 604

    Aug 9, 2009
    Set the Primary Button to the right button:
    defaults -currentHost write -g \
      "" -int 1
    Set the Primary Button to the left button:
    defaults -currentHost write -g \
      "" -int 0
    Set Spaces to 1 row, 3 cols, enabled:
    defaults write "workspaces-cols" -int 3
    defaults write "workspaces-rows" -int 1 
    defaults write "workspaces" -int 1 
    May not take effect immediately. You may have to logout and login again.

    Some other settings not obviously Dock-related are also in Hot-corners, for example:
    defaults read | grep wvous
    Google the names it finds and you'll see the relationships.

    A number of Exposé and hot-key settings are here:
    defaults read
    The general approach is to redirect output to a file, e.g. 's1'. This establishes the current state. Then go to the System Preferences pane and change a setting. Close the window. Run the command again, redirecting output to a different file, e.g. 's2'. Then find differences:
    diff s1 s2

    If differences appear, isolate which line they're on, then figure out the 'defaults' command-line to change the setting.

    If no differences appear, then the settings isn't stored in that preferences file.

    Another command for working with plists is PlistBuddy. Google it.

    You might also be able to do GUI Scripting on the pref-pane. For example, see here:

    or google keywords: system preferences gui scripting
  5. Monaj thread starter macrumors regular

    May 24, 2009
    thanks tone for the commands :)

    Just one more question... can I do it via any apple script command?
  6. chown33 macrumors 604

    Aug 9, 2009
    GUI Scripting is AppleScript. Click the link I posted, and do the google search I gave.
  7. Monaj thread starter macrumors regular

    May 24, 2009
    once again thanx :)

Share This Page