|
|
10.5: Sleep all displays via keyboard shortcut
Here is an email I wrote where I got the password bit to work via a hotcorner, I don't have time to format it or anything:
> System Preferences --> Security > Check the box requiring password to wake this computer. . . Sadly that does not quite work. I had the "Hot Corners..." set to "Sleep Display" and it would not ask me for password on wake-up. I have a solution though: First I came across this post: http://www.cocoabuilder.com/archive/message/cocoa/2007/11/3/192200 Re: Sleep Display FROM : Andrew Farmer DATE : Sat Nov 03 23:22:37 2007 On 30 Oct 07, at 15:33, Andrew James wrote: > I noticed steve added the nice feature to sleep the display via a hot > corner, but is there a way for us devs to hook into it? I am > currently using > a pmset hack which i would prefer to use a cleaner method Undocumented, use at your own risk, etc. It ends up involving more IOKit than Cocoa, as it turns out. #include <CoreFoundation/CoreFoundation.h> #include <IOKit/IOKitLib.h> int dimDisplayNow(void) { io_registry_entry_t r = IORegistryEntryFromPath(kIOMasterPortDefault, "IOServic e:/IOResources/IODisplayWrangler"); if(!r) return 1; int err = IORegistryEntrySetCFProperty(r, CFSTR("IORequestIdle"), kCFBooleanTru e); IOObjectRelease(r); return err; } Then I found this: http://www.imalc.com/Site/SleepDisplay.html I disassembled the x86 version and see that it does just what that post said. Then I needed a Screen Saver that could run arbitrary programs: http://swannman.wordpress.com/projects/scriptsaver/ The bonus is that ScriptSaver comes with source code as well. Now it only runs AppleScripts so I make this one-liner: do shell script "exec /usr/local/bin/sleepdisplay" I compiled it like so: osacompile -o sleepdisplay.scpt sleepdisplay.applescript You can see from the AppleSript that I copied the sleepdisplay binary from SleepDisplay.app/Contents/MacOS and I put sleepdisplay into /usr/local/share/osascript. Then I made ScriptSaver my Screen Saver (by copying it into /Library/Screen Savers) and selecting it in the "Other" list in the Screen Saver tab of the Desktop & Screen Saver System Preferences panel. Set some reasonable time-outs and made the Hot Corner "Start Screen Saver" and finally the Security option mentioned in the reply worked. Phew... |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.05 seconds |
|