Is there a way to turn battery saver on/off?

I can only find API calls to read the system settings, not to set them, but maybe there is another way to do this that I haven't found yet?