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

bravencarver

macrumors newbie
Original poster
Apr 22, 2011
2
0
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
 

larkost

macrumors 6502a
Oct 13, 2007
534
1
Can you be more specific about what you are doing, and why you need the screensaver to run?
 

bravencarver

macrumors newbie
Original poster
Apr 22, 2011
2
0
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
 

gnuguy

macrumors newbie
Nov 25, 2006
15
0
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.
 

larkost

macrumors 6502a
Oct 13, 2007
534
1
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}'
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.