Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
The power settings can dim screen. Besides that: install jupiter (it works wonders on my system). askubuntu.com/questions/98972/… –  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/ –  dhojgaard Apr 20 '13 at 10:53
add comment

1 Answer 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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.