Editing System Prefs

Discussion in 'Mac Programming' started by jnoxx, Jun 17, 2011.

  1. jnoxx macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    Hey everyone,

    I code iOS alot. But I tried taking a step to the Mac OSX, after one of my collegues asked me to make something "little", all I want to do, is create a YES/NO Function for a certain System Setting.
    So let's say I want to disable a certain System setting, like, "Expose" by code.
    Is it possible, couldn't find a good google answer, only 1 on stackoverflow, but no one answered there ;)

    Thanks alot :)

    Regards, Noxx
  2. subsonix macrumors 68040

    Feb 2, 2008
    If it's a certain system setting, why don't you mention exactly what it is instead of an unrelated example.
  3. robbieduncan Moderator emeritus


    Jul 24, 2002
    In general the answer is no. It may be possible by gaining admin access and altering specific plist files that represent the preferences or by using GUI Applescripting.
  4. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    I think the general answer is "Maybe", and it may need some detective work.

    Many preferences are stored here:
    They are usually plist files, so they can be read and written using the 'defaults' and 'plutil' commands.

    The detective work is figuring out which file, where it's located, and which key belongs to which GUI element in the prefpane. Even then, it may not be accessible easily. For example, the Time Machine disk is stored as a data object, probably an alias-record.

    System-wide preferences are stored here:
    and they may be writable without elevated privileges.

    There are other places that settings might be stored. It depends on the pref-pane, so knowing exactly what setting to change is crucial.

    Certain system configuration preferences are stored here:
    and they should only be accessed by the 'scutil' command.

    There are other specific commands that are the proper way to access a configurable element, rather than 'defaults' or 'plutil'. This command lists them:
    ls -1 /usr/*bin/*{util,setup}
    Then plug their names into the 'man' command to read their respective man pages.

    If necessary, use the 'authopen' command for elevating privileges, rather than 'sudo'. See 'man authopen'.
  5. Hansr macrumors 6502a

    Apr 1, 2007
    Provided your application runs with admin priv or prompts the user for admin privs on the execution of the command you can spin up a CLI process and just send:

     defaults write com.apple.dock mcx-expose-disabled -bool true ;killall Dock

Share This Page