Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

fletch22

macrumors newbie
Original poster
May 9, 2007
1
0
Hi-

I am wondering if there is a c/c++ API for the system preferences that I can use to disable the screen saver. I'd like to do this:

* read the settings that the user has (how long until screen saver activates, etc)
* disable it
* when my app exits, re-enable the settings saved previous.

Thanks!
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
The basic answer is no.

You might be able to get access via the the CFPreferences API if you know the correct AppId & Domain to pretend to be that preference pane, but there is no guarantee that updating the preference behind the back of the preference pane and screen saver system would work: you may need to inform it via some private API that this has changed.

Edit to add: a better way would be to not monkey around with the users settings (what if your app crashes). Instead stop the screen saver activating at all. A possible way of doing that is discussed here.
 

garethlewis2

macrumors 6502
Dec 6, 2006
277
1
What you are asking to is take control of the machine and cirumvent any user authority. There is absolutely no way that Apple would ever create an API that allowed that, while running Aqua. The only way to do something like this, is to create a windowless app that runs full screen, something like a game or FrontRow.
 

whooleytoo

macrumors 604
Aug 2, 2002
6,607
716
Cork, Ireland.
What you are asking to is take control of the machine and cirumvent any user authority. There is absolutely no way that Apple would ever create an API that allowed that, while running Aqua. The only way to do something like this, is to create a windowless app that runs full screen, something like a game or FrontRow.

I'd be surprised if some apps don't already do this, such as DVD player and Quicktime player.

There is one way I can think of to do this indirectly that would almost certainly work, but may or may not be suitable for the OP. I am curious why he needs to do this though.
 

Nutter

macrumors 6502
Mar 31, 2005
432
0
London, England
I'd be surprised if some apps don't already do this, such as DVD player and Quicktime player.

Why would DVD Player and QuickTime Player do this? They probably just update the system activity timer.

Actually disabling the screen saver to stop it from appearing is a bit of a hack! Imagine if your app crashes or is force quit - the user will never see their dear screen saver again.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Why would DVD Player and QuickTime Player do this? They probably just update the system activity timer.

Actually disabling the screen saver to stop it from appearing is a bit of a hack! Imagine if your app crashes or is force quit - the user will never see their dear screen saver again.

They almost certainly use the technique I posted a link to above (updating the activity timer).
 

whooleytoo

macrumors 604
Aug 2, 2002
6,607
716
Cork, Ireland.
Why would DVD Player and QuickTime Player do this? They probably just update the system activity timer.

Actually disabling the screen saver to stop it from appearing is a bit of a hack! Imagine if your app crashes or is force quit - the user will never see their dear screen saver again.

Sorry, I was referring to disabling the screen saver, rather than that specific method of disabling it. As you say, there are obvious disadvantages in that method.

Updating the system activity is 'the' way to do it, and is what we use in our Mac apps.

Incidentally, what the OP wants could be done via GUI scripting, though it would be rather messy.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.