• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: controlling display sleep
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: controlling display sleep


  • Subject: Re: controlling display sleep
  • From: arri <email@hidden>
  • Date: Sat, 28 Apr 2007 11:31:52 +0200

thank you ron!

appearantly this is the right approach.
i'll just have to accept the 1 minute delay then.


regards, . arri


On Apr 16, 2007, at 10:44 AM, Ron Fleckner wrote:


On 16/04/2007, at 5:35 PM, arri wrote:


hoi list,


i'd like to have control over the power-managers' display sleep status.
ideally i would like to control the display sleep directly from my code.


the best solution i have found so far would be to set an as short
displaysleep-delay as possible in system-prefs or using pmset(), and
then keep the screen awake by calling UpdateSystemActivity() at
regular intervals.
then whenever i want the screen to sleep i would stop calling
UpdateSystemActivity(), and about a minute later the screen goes to
sleep...

is there a better or more direct way to do this?

in this case it is for a kiosk application, so the human-interface
guidelines don't apply.

thanks,
arri

Hi arri,
I'm certainly no expert, but this is what I did after reading the tech note shown in the comment below. keepAwakeTimer is an instance variable so it's easy to tell it to stop when you want to. Works fine.


Ron

- (void)preventSleep
{
keepAwakeTimer = [[NSTimer scheduledTimerWithTimeInterval:30 target:self selector:@selector(stayAwake:) userInfo:nil repeats: YES] retain];
}
- (void)stayAwake:(NSTimer *)sleepTimer
{
UpdateSystemActivity(OverallAct);// This is from Apple Tech Note QA1160:Preventing Sleep
}


-----
Scanned for virus and spam

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: controlling display sleep (From: Ron Fleckner <email@hidden>)

  • Prev by Date: [Moderator] List guidelines and related resources
  • Next by Date: [ANN] F-Script 1.3.5
  • Previous by thread: Re: controlling display sleep
  • Next by thread: I want to change the background of NSWindow.
  • Index(es):
    • Date
    • Thread