4

Is it possible to tweak settings if and only if the computer starts on battery power?

Why?

I usually work without battery, but when I use a battery I want it to last as long as possible. For that purpose I use little tweaks (granola for minimal power consumption, switching off wifi and bluetooth, and brightness settings).

What?

Whenever I boot my laptop on battery I have to manually tweak all these settings. In the beginning that was OK, but now I want these tweaks to be done automatically. What I want to be tweaked automatically when booting on battery power is

  1. setting the laptop in flight mode (no wifi nor bluetooth)

  2. dimming the screen to 50%

  3. disabling all usb inputs (I often leave a few things in usb slots, but I do not want them activated)

  4. set the power mode in granola to minimal consumption (this needs sudo).

Any ideas? A script that runs automatically when logging in on battery? Anything?

don.joey
  • 28,402
  • 17
  • 82
  • 104
  • The power settings can dim screen. Besides that: install jupiter (it works wonders on my system). http://askubuntu.com/questions/98972/does-jupiter-really-improves-battery-power – Rinzwind Apr 12 '13 at 14:33
  • Hi Rinz, my screen does not dim automatically on battery power (12.10, Lenovo Ideapad Z580). – don.joey Apr 12 '13 at 14:35
  • Regarding the dimming of the screen, this post explains a lot: [http://www.vivaubuntu.cu.cc/dim-screen-backlight-on-when-on-battery/](http://www.vivaubuntu.cu.cc/dim-screen-backlight-on-when-on-battery/) – dhojgaard Apr 20 '13 at 10:53

1 Answers1

1

You can insert your custom battery-saver commands to an executable file like this under folder "/etc/pm/power.d":

#!/bin/bash
if on_ac_power; then
    : # Do nothing
else
    rfkill block bluetooth # Turn OFF bluetooth
fi
exit 0

You can see a list of other options using PowerTOP utility.

Sadi
  • 10,912
  • 7
  • 48
  • 61