Auto-shutdown at login window

Discussion in 'macOS' started by bendrucker, Oct 31, 2010.

  1. bendrucker macrumors newbie

    Mar 14, 2010
    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?
  2. larkost macrumors 6502a

    Oct 13, 2007
    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:
    /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.
  3. bendrucker thread starter macrumors newbie

    Mar 14, 2010
    Thank larkost. I'll give your suggestions a shot and will post if (or more likely when) I run into problems.
  4. Darth.Titan macrumors 68030


    Oct 31, 2007
    Austin, TX
    Your Mac should power down the display, sleep, or whatever even at the login prompt. I know mine does.
  5. bendrucker thread starter macrumors newbie

    Mar 14, 2010
    Well then I'll have to do some experimenting with Energy Saver settings before I dig into any shell scripting.

Share This Page