acpid - Hibernate When Unplugged

view story

http://unix.stackexchange.com – I'm new to programming for Linux (lubuntu specifically) and I'm working on a project to get an old, discarded laptop up and running the way I want it. I have acpi and acpid installed, and when I run the acpi command, I am informed of whether my laptop is plugged in (charging) or unplugged (discharging). I would now like to have the laptop automatically hibernate when the laptop is discharging. My first though was to write a script that would poll acpi every 30 seconds or so and then run a hibernate command whenever it responded with the word "discharging". However, I understand that acpid is (HowTos)