Configure power button to shutdown on Debian/Mac Mini G4

acpipowerpcshutdown

I use Debian/PPC on an old Mac Mini G4, it currently serve as a DLNA server (UPnP), no mouse or keyboard plugged.

I would like that my power button also serves to shutdown the box. Currently it does nothing, on recent x86 I would have used ACPI as described here.

However ACPI does not seems to be available from my G4 box (see for example here or here), only pbbuttonsd is available, see link.

I could not find whether or not any event (APM type?) is sent when pressing the power button. I know that I can hold the power button for 4s then the machine halt, but I would prefer a clean shutdown. As a last resort I could plug in a keyboard but I am looking for a solution without mouse or keyboard.

How would one do that ?

EDIT: Using web.archive.org I was able to read: http://web.archive.org/web/20110317165103/http://blog.blinker.net/2010/06/20/mac-mini-g4-homeserver-with-ubuntu-linux-10-04-wpa2/

I used the solution suggested:

I got this working on my G4 Quicksilver with Ubuntu by installing
pbbuttonsd.

I had to modify /etc/pbbuttonsd.conf and change this line:

OnAC_KeyAction = none

to:

OnAC_KeyAction = shutdown

I ran /etc/init.d/pbbuttonsd restart to restart the daemon, and then
the power button worked to trigger a clean shutdown.

But this did not work for me, maybe there is a difference in between PowerBook and Mac Mini G4.

Best Answer

After digging into the source code, I was able to suggest the following patch on the pbbuttons mailing list, as seen here.

Turns out the code would only consider a power button press event in case:

if (n == 6 && ((intr[1] >> 3) & 1) != PBpressed) {

while the comment just above explains that:

/* n = 2 && intr[1] = 0x0c = %01100 power button on mac-mini */

so I simply changed it to:

if (n == 2 && intr[1] == 0x0c ) {

Now I can properly configure the OnAC_KeyAction to shutdown ! No need for a keyboard for a simple action like this now !

Related Question