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 Apr 22, 2011, 12:10 PM   #1
bravencarver
macrumors newbie
 
Join Date: Apr 2011
Scripting Screensaver

Hello all!

So here is my dilemma, I'm connecting an iPad to a mac mini via an app called Screens which uses VNC. When a computer is connected via VNC it doesn't want to go to sleep or activate screensaver. Well I need that to happen. I found a workaround in an app called PowerManager, which has a function that states "run script after ___ amount of inactivity, and it works and starts the screensaver even while connected to VNC! but it is $50 and I have to put it on multiple machines. I only need this one function, so I was hoping to write an applescript that basically does the following,

after 8min of inactivity run screensaver.app

and that script obviously has to be running continuously.

So yeah, any help would be much appreciated, I haven't done too much scripting but I can follow instructions.

Thank you!

Braven Carver
bravencarver is offline   0 Reply With Quote
Old Apr 22, 2011, 11:31 PM   #2
larkost
macrumors 6502a
 
Join Date: Oct 2007
Can you be more specific about what you are doing, and why you need the screensaver to run?
larkost is offline   0 Reply With Quote
Old Apr 25, 2011, 10:48 AM   #3
bravencarver
Thread Starter
macrumors newbie
 
Join Date: Apr 2011
Scripting Screensaver

Hello,

I need the screensaver to run even when connected to VNC, because the iPads will always be connected even when you re-dock them. I need the screensaver to run after inactivity to 1) show something appealing instead of the last window that was up and 2) to keep the image from burning in (some of the tv's we're doing this with are older plasmas)

Thanks,

Braven Carver
bravencarver is offline   0 Reply With Quote
Old Apr 25, 2011, 11:16 PM   #4
gnuguy
macrumors newbie
 
Join Date: Nov 2006
make sure you add the applicationServices framework then use

Code:
double	idleTime;
idleTime = CGEventSourceSecondsSinceLastEventType(kCGEventSourceStateHIDSystemState, kCGAnyInputEventType);
This will give you the time in seconds that the system has been idle.
gnuguy is offline   0 Reply With Quote
Old Apr 26, 2011, 11:41 PM   #5
larkost
macrumors 6502a
 
Join Date: Oct 2007
gnuguy, I had never seen the Carbon call for that, and had always worked my way thorough ioreg for it. Using Carbon is so much easier! And in case someone is looking for a script-ish way of doing it:

Code:
/usr/sbin/ioreg -c IOHIDSystem | /usr/bin/awk '/HIDIdleTime/ {print $NF/1000000000; exit}'
larkost 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
I need help with some scripting flash1996 Mac Basics and Help 0 Mar 30, 2014 08:01 PM
Need help: Perl scripting iAintKnowMac Mac Programming 5 Jul 2, 2013 09:28 PM
In need of scripting advice ebobster Mac Programming 1 May 15, 2013 09:26 AM
Scripting Outlook sitryd Mac Programming 2 Mar 14, 2013 11:28 AM
Keynote scripting activate Mac Programming 2 Nov 1, 2012 01:33 AM

Forum Jump

All times are GMT -5. The time now is 04:29 PM.

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

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