Friday, November 24, 2006

KPowersave config tutorial

As wrote in my last post about the current KPowersave release 0.7.1 there are some settings which the user can't change at the moment via the configure dialog. Here now a small tutorial how to control this settings via the KPowersave config file.

You can control the settings for these options:
  • battery warning levels
  • actions for battery warning levels and lidclose
  • default AC and battery scheme
  • CPU frequency policy for each scheme
To change the config keys for these options you need to open in your home with a editor of your choise this file (if the file is not present, create the file): ~/.kde/share/config/kpowersaverc

KPowersave provide three different battery warning levels: warning, low and critical. To define the percentage (between 0 and 100) of battery fill for these levels you need to edit config keys in the section [General]. If the section is not there, simply add a line with [General] at top of the file and add/edit these keys there :
batteryWarning=12
batteryLow=7
batteryCritical=2
You can also define a action (currently only one per level) which is called if one of the battery warning levels reached. The available actions are:
  • shutdown the machine (SHUTDOWN)
  • suspend to disk (SUSPEND2DISK)
  • suspend to ram (SUSPEND2RAM)
  • change the CPU freqency policy to 'performance' (CPUFREQ_POWERSAVE) or 'dynamic' (CPUFREQ_DYNAMIC)
  • change the brightness if supported by your hardware (BRIGHTNESS)
To define the actions for the battery warning levels you have to change this keys (also in the section [General]):
batteryWarningAction=
batteryLowAction=BRIGHTNESS
batteryCriticalAction=SHUTDOWN
The values in this example are the already defined defaults, so you don't need to add/change the keys if this is what you want. For the action BRIGHTNESS you need an additional key for each level to define the level (in percentage) of brightness to set:
batteryWarningActionValue=
batteryLowActionValue=
batteryCriticalActionValue=
You can use the same actions and values as for battery warning levels also for the event if the lid of your laptop get closed. To control the behavior you need to change these keys:
ActionOnLidClose=
ActionOnLidCloseValue=
To control which scheme KPowersave should use on battery or on AC you need to know the names of the available schemes. You can find them in this file: /opt/kde3/share/config/kpowersaverc . Currently there are (excluding the [default-scheme]) these schemes per default: Performance, Powersave, Presentation and Acoustic. To set the schemes you have to change these keys:
ac_scheme=Performance
battery_scheme=Powersave
At least you can change the CPU frequency for each scheme. For this you need, if not already there, for each a own section in the config file (a section starts with the name of the scheme withing '[ ]'). The available CPU frequency policies are: PERFORMANCE, POWERSAVE and DYNAMIC. Here a example for the performance scheme:
[Performance]
cpuFreqPolicy=DYNAMIC
If you canged all you want, you need to restart KPowersave to apply the changes.

15 comments:

Anonymous said...

[General]
ActionOnLidClose=SUSPEND2RAM
...
does not work with opensuse-10.2 on samsung x20.

Anonymous said...

Is there any way to capture the "power butto pressed" event and associate and action to it?

Anonymous said...

It Works quite well on my Toshiba M40-JM8 with omnibook-2.20060921 kernel module on kubuntu Dapper
However

[Performance]
brightnessPercent=100
...
does not work automatically when i plugged the AC ...

while
[Powersave]
brightnessPercent=40
...
works automatically.

Danny said...

[quote]Is there any way to capture the "power butto pressed" event and associate and action to it?[/quote]

Unfortunately not with this version (v0.7.1) but with the next package (v0.7.2), I plan to release this weekend.

calocen said...

In case of:
ActionOnLidClose=SUSPEND2RAM

Be sure that powersave has bit suid.

Anonymous said...

In case of:
ActionOnLidClose=SUSPEND2RAM

Be sure that powersave has bit suid.

why should that help?

does it work with opensuse-10.2 for anybody?

Danny said...

[quote]does it work with opensuse-10.2 for anybody?[/quote]

At least it works for me with 10.2, but you can also try the package, which is a candidate for the next version and a YOU update for 10.2:
http://beta.suse.com/private/dkukawka/kpowersave/0.7.2pre/

Anonymous said...

On opensuse 10.2 did you set S2RAM_OPTS="-f" in /etc/pm/config? This will force suspend to RAM on machines not KNOWN to work with s2ram.

Klaus said...

I need to execute some some alsactr commands before and after a suspend cycle to restore sound on my Dell X200.

(before suspend)
alsactl store
alsactl -f /etc/asound.zero restore

(and after)
alsactl restore

Is this possible from kpowersave (or does these commands belong otherwere)?

Regards

Danny said...

No this is not possible. One reason is that KPowersave can't call root commands.

The second is: instead of workaround this in/via KPowersave this problem should get fixed in the kernel.

Please report this to the kernel ALSA developer. If you are a openSUSE user you can do this also via bugzilla.novell.com, otherwise you should report this to: Takashi Iwai via linux-kernel@vger.kernel.org . He/they fix such problems normaly very fast.

Klaus said...

I see. But the X200 is a very old notebook. I guess most of them dead and gone by now. So one might think it is taking the matter a little to far to ask for a kernel mod.

Thanks anyway.

Danny said...

How old is the laptop? 4 years? What kind of soundcard is this? IMO you can ask Takashi Iwai (you can find his mail address here: http://www.alsa-project.org/~iwai/) anyway, if he don't want to patch this he will tell you. ;-)

If this get not fixed in the kernel you can add a hook to the underlaying tool which execute the suspend called by KPowersave via HAL. On SUSE and some other distributions is this e.g. pm-utils (e.g. http://en.opensuse.org/Pm-utils)

Klaus said...

Think I bought it in summer 2001 - not really sure. But you are right, I will send a note to Takashi and let him decide.

But thanks for the pointer to PM-utils. The tutorial on that page was easy to modify to my purpose.
--
Regards

Barcode said...

Is there any way to get the main window to show battery status in percent instead of time to charge/discharge?

Anonymous said...

i have this error when i launch kpowersave --force-acpi-check:
This machine does not support ACPI, APM, PMU, CPUFreq, Suspend2Disk norSuspend2RAM. Close KPowersave now.
ERROR: Communication problem with kpowersave, it probably crashed.
i think that is for a missing option in the kernel because i have this problem only with my own compiled kernel, but i cannot find what option is.
can you help me?
thanks a lot.