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]m 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 thought 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 the better tool to use, as it is more event-driven. I can't seem to find any material on making a laptop hibernate when unplugged - any advice?