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

bendrucker

macrumors newbie
Original poster
Mar 14, 2010
29
0
My parents share a Mac Mini. Often when I'm at their house, I notice that it's been left at the login screen. Presumably one person logged out thinking they were leaving the computer available for the other and then never put it to sleep at the login screen. The issue is that Energy Saver prefs don't seem to apply when there is no user logged in. The computer just sits there with the login window display indefinitely. It never goes to sleep or turns the display off.

Is there any way to have some sort of daemon run only while no one is logged in that would either shut down the computer or put it to sleep after a specified number of minutes of being idle at the login screen? While the Mac Mini is a very energy efficient computer, it still makes no sense for it to be on for dozens of hours each week unnecessarily. Any ideas?
 

larkost

macrumors 6502a
Oct 13, 2007
534
1
Are you sure that the power options don't apply at the LoginWindow? I remember them applying fine, since they are necessarily computer-wide (not even specific for the running OS). It is the ScreenSaver options that don't apply to the LoginWindow unless you make some modifications (note: I am the author of the script referenced, but there are more comments on Greg's site that might be helpful).

However, the way to do this would be to create a script and launch it as a LaunchAgent with the LimitLoadToSessionType set to "LoginWindow". Then inside the script you just use something like this line:
Code:
/usr/sbin/ioreg -c IOHIDSystem -d 4 | /usr/bin/awk '/Idle/ { print $4 }'
to get the number of second idle (note: it is retuned in nanoseconds, so you will probably want to divide by 1,000,000,000 to get seconds). Then when your threshold is crossed you do whatever you want to do.
 

bendrucker

macrumors newbie
Original poster
Mar 14, 2010
29
0
Thank larkost. I'll give your suggestions a shot and will post if (or more likely when) I run into problems.
 

bendrucker

macrumors newbie
Original poster
Mar 14, 2010
29
0
Well then I'll have to do some experimenting with Energy Saver settings before I dig into any shell scripting.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.