On 13-02-17 08:52 PM, Stefan Monnier wrote:
Hi guys, any ideas how I could get a laptop running debian or ubuntu to shut
itself down when the power is lost? I have looked at pm-utils but this seems
to be only for suspend/hibernate.
Put a script in /etc/pm/power.d/.  This script will be called with one
argument which is "true" when AC is lost and "false" when AC comes back.

This does not arrange to start the computer when the power comes back.
For that I'm not sure what you need to play with, OTOH.


         Stefan

Thanks Stefan!

I finally got around to doing this after some trouble with adapters :(

Here is the script which is in /etc/pm/power.d/my-power-script.sh

----

#!/bin/sh

. "${PM_FUNCTIONS}"

case $1 in
    true) #laptop_mode_battery
                logger "on battery"
                shutdown -h +20
        ;;
    false) #laptop_mode_ac
                logger "plugged in"
                shutdown -c "power restored"
        ;;
    help) help;;
    *) exit $NA ;;
esac

exit 0

----

Thanks,

Jeremy
_______________________________________________
mlug mailing list
[email protected]
https://listes.koumbit.net/cgi-bin/mailman/listinfo/mlug-listserv.mlug.ca

Reply via email to