Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
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 68030
 
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 offline   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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Desktop System Pref panel crashes my System Preferences GanChan Mac Basics and Help 1 Apr 8, 2008 10:09 AM
WTF is wrong with my system Prefs? Royal Pineapple Mac Help/Tips 4 Mar 22, 2003 08:16 PM
My System Prefs are GONE!!! Well most of them LimeiBook86 Mac Help/Tips 4 Dec 17, 2002 08:46 PM
Bluetooth System Prefs bplamotte Mac Help/Tips 0 Oct 12, 2002 07:56 PM
simple system prefs question jelloshotsrule Mac Help/Tips 3 Aug 25, 2002 12:46 AM


All times are GMT -5. The time now is 06:32 AM.

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

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