Power LED Heartbeat script
#4
Thumbs Up 
tkaiser Wrote:Did you try out installation of acpid package? See here for example: http://forum.armbian.com/index.php/topic...e/?p=11137

Had a look at the acpid package, and it worked beautifully. The acpi_listen command returned

Quote:button/power PBTN 00000080 00000000

just like in your example for the Beelink X2 when I pressed the pine64s power button, so I did a line similar to yours:

Quote:echo -e 'event=button/power\naction=/etc/acpi/trigger-shutdown.sh' >/etc/acpi/events/powerbtn

However my script is a little different as it kills the heart-beat script, kills the rapid flash script just in case the button is pressed multiple times,  runs a rapid flash system led flash script, and then does requests shutdown with 2 minutes grace. Could be a lot better still, at least it gives a little warning before the pine64s untimely demise.  Wink  I also need to work out how to handle the case where the shutdown is canceled, so it can resume the heartbeat (perhaps also making it one script that can switch modes?), but that is a problem for another day.

Quote:#!/bin/bash
ps aux | grep -ie pine64-SYSLED-heartbeat | grep -v grep | awk '{print $2}' | xargs kill -9
ps aux | grep -ie pine64-SYSLED-rapid | grep -v grep | awk '{print $2}' | xargs kill -9

/usr/local/sbin/pine64-SYSLED-rapid.sh &
shutdown -h +2
Obviously, if you just want the pine64 to basically drop dead gracefully initiate shutdown on the press of the power button... you could still do this instead:
Quote:echo -e '#!/bin/bash\nshutdown -h now' >/etc/acpi/trigger-shutdown.sh

And of course, don't forget to


Quote:chmod 755 /etc/acpi/trigger-shutdown.sh

Thanks for the examples and hint! Smile
  Reply


Messages In This Thread
Power LED Heartbeat script - by pfeerick - 09-18-2016, 05:16 AM
RE: Power LED Heartbeat script - by tkaiser - 09-18-2016, 06:25 AM
RE: Power LED Heartbeat script - by pfeerick - 09-18-2016, 05:43 PM
RE: Power LED Heartbeat script - by pfeerick - 09-20-2016, 04:49 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)