Apple Script for system preferences

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

  1. Monaj macrumors regular

    Joined:
    May 24, 2009
    #1
    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!

    Monaj
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    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

    Joined:
    May 24, 2009
    #3
    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?

    Thanks,

    Monaj
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    Set the Primary Button to the right button:
    Code:
    defaults -currentHost write -g \
      "com.apple.mouse.swapLeftRightButton" -int 1
    
    Set the Primary Button to the left button:
    Code:
    defaults -currentHost write -g \
      "com.apple.mouse.swapLeftRightButton" -int 0
    
    Set Spaces to 1 row, 3 cols, enabled:
    Code:
    defaults write com.apple.dock "workspaces-cols" -int 3
    defaults write com.apple.dock "workspaces-rows" -int 1 
    defaults write com.apple.dock "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 com.apple.dock. Hot-corners, for example:
    Code:
    defaults read com.apple.dock | grep wvous
    
    Google the names it finds and you'll see the relationships.


    A number of Exposé and hot-key settings are here:
    Code:
    defaults read com.apple.symbolichotkeys
    
    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:
    http://www.macosxautomation.com/applescript/uiscripting/index.html

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

    Joined:
    May 24, 2009
    #5
    thanks tone for the commands :)

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

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

    Joined:
    May 24, 2009
    #7
    once again thanx :)
     

Share This Page