Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 17, 2011, 08:17 AM   #1
jnoxx
macrumors 65816
 
jnoxx's Avatar
 
Join Date: Dec 2010
Location: Aartselaar // Antwerp // Belgium
Editing System Prefs

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
jnoxx is offline   0 Reply With Quote
Old Jun 17, 2011, 08:48 AM   #2
subsonix
macrumors 68040
 
Join Date: Feb 2008
If it's a certain system setting, why don't you mention exactly what it is instead of an unrelated example.
subsonix is offline   0 Reply With Quote
Old Jun 17, 2011, 09:15 AM   #3
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
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.
robbieduncan is offline   0 Reply With Quote
Old Jun 17, 2011, 12:25 PM   #4
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by robbieduncan View Post
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.
I think the general answer is "Maybe", and it may need some detective work.

Many preferences are stored here:
Code:
~/Library/Preferences
~/Library/Preferences/ByHost
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:
Code:
/Library/Preferences
/Library/Preferences/ByHost
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:
Code:
/Library/Preferences/SystemConfiguration
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:
Code:
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'.
chown33 is online now   0 Reply With Quote
Old Jun 17, 2011, 01:06 PM   #5
Hansr
macrumors 6502a
 
Join Date: Apr 2007
Quote:
Originally Posted by jnoxx View Post
So let's say I want to disable a certain System setting, like, "Expose" by code.
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:

Code:
 defaults write com.apple.dock mcx-expose-disabled -bool true ;killall Dock
Hansr is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
How do I remove deleted apps from System Prefs Pndrgnsvc OS X Mavericks (10.9) 9 Oct 31, 2013 04:49 PM
Displays in System Prefs. Won't open will0407 OS X 2 Sep 15, 2013 11:11 AM
10.6.8 System Prefs Crashing npaisnel OS X 0 Jun 23, 2013 10:17 AM
My System Prefs not saved after rebooting Curtland1 MacBook Pro 1 Mar 21, 2013 05:45 AM

Forum Jump

All times are GMT -5. The time now is 02:28 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC