This should probably be done as a patch to gnome-power-manager.
Thinkpad laptops in particular already do something like this (it's
implemented in the BIOS) that does a chime to notify the user that the
laptop is still on when the lid is closed and the power cord is detached to
prevent people
Dear GNOME developers,
I have a program idea that I would like to create and test out, but I
have no idea whether something like this has already been created and
what documentation to read in order to create it.
I want an application that will sound an alarm if my laptop adapter is
unplugged