Ubuntu – Automatically shutdown when switching to battery


I'm recently made my old laptop into a server using Ubuntu Desktop 15.04.
But because my laptop has an almost dead battery I want Ubuntu to save all data that it's on (or at least close the running programs) and safely shut down.
How can I make sure Ubuntu does this when the AC adapter is unplugged?

I might be able to get this done easily by just adjusting the critical battery level to 95-ish. But I don't know what Ubuntu does during shutdown at critical battery level. If this could be the fix then I'd like to know: what does Ubuntu do when shutting down at critical battery level?

Best Answer

The package that handles the AC-to-battery transition is pm-utils. On a command line, looking at the files in the pm-utils package will tell you where to go next:

    $ dpkg -L pm-utils