Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I make my linux system (ubuntu) automatically choose the performance governor when it works with ac and switch automatically to ondemand when it is on battery (and vice versa)?

Is it also possible to switch to the lowest CPU frequency if the battery state drops below a certain value?

I am looking for a solution which is independent of the used desktop environment.


The solution may interfer with another cpu scaling mechanism installed in ubuntu by default. For example there is a file /etc/init.d/ondemand which sets the CPU to ondemand...

Are there other pitfalls like this one?

share|improve this question

You could use laptop-mode-tools. You can specify the governor and max/min frequency while on AC or BATTERY via config files. (Archwiki page)

Another option which gives you more control (rules per battery level) is Cpufreqd (thinkwiki page).

You can also tune your cpu based on acpi events (Archwiki page)

share|improve this answer

Your Answer


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.