Add power management stuff (#284, #490). Needs testing

Heavily untested except on Arch Linux.