React to pressing Mac Mini power button in script

Discussion in 'Mac Programming' started by jhaspell, Aug 13, 2008.

  1. jhaspell macrumors newbie

    Feb 17, 2008

    I'm not sure if this is even possible but I figured this was the best place to ask :)

    I have a Mac Mini and am currently using it under my TV to stream audio and video to a couple of AV devices (for example Slimdevices Squeezebox).

    It currently has no keyboard, mouse or monitor connected - only power and wired ethernet.

    Is it possible to write an automator (or similar) script to react to a manual press of the physical power button? I would like to issue a shutdown command to the machine on pressing it.

    I know pressing the button for 6 seconds powers off the Mac but I figured that this won't do the machine any good in the long run and it would be better to take it down gracefully.

    Thank you for your help.

  2. robbieduncan Moderator emeritus


    Jul 24, 2002
    I don't think it's possible to catch this event using an Automator or even Apple Script app. I think a distributed notification gets posted when the machine will got to sleep or will shutdown, but that's after the user chooses one of the options when the button gets presses (these notifications could be caught by a Carbon or Cocoa app).

    Probably the easiest solution is to enable SSH (if it's not already available) and use that to remotely shutdown the machine from another computer.
  3. jhaspell thread starter macrumors newbie

    Feb 17, 2008
    Thank you for the reply Robbie.

    I am trying to avoid having to connect to the machine from elsewhere, as the Mac which is streaming data needs to be turned off / on by people with little or no knowledge of computers.

    I am going to have a look at the "Remote Buddy" application. Hopefully this will allow me to add some shutdown commands from my Pronto IR remote control, which can achieve the same result.


Share This Page