Results 1 to 7 of 7

Thread: Automatically change processor settings when changing to/from battery on laptop

  1. #1
    Join Date
    Aug 2007
    Location
    Saint Louis, MO. USA
    Beans
    214
    Distro
    Ubuntu 14.04 Trusty Tahr

    Automatically change processor settings when changing to/from battery on laptop

    Does anyone know how I would write a script that would automatically change my processor settings to conservative when switching to battery, and back to performance when switching to A/C?

    I am running Ubuntu 10.04 and I already have my processors set to performance by default.

    Thanks,

    Neil

  2. #2
    Join Date
    Dec 2009
    Beans
    167

    Re: Automatically change processor settings when changing to/from battery on laptop

    If you're using a command-line tool, such as cpufreq-set, to set manually the laptop's performance/conservative modes, then it's not that hard to implement such a script. If so, post that command(s) and the output of these commands:

    Code:
    find /proc/acpi/battery/ -ls
    
    find /sys/class/power_supply/
    
    ls -l /sys/class/power_supply/AC0/online
    Otherwise if you're using a GUI tool, it might not be that trivial, at least from my viewpoint.

  3. #3
    Join Date
    Aug 2007
    Location
    Saint Louis, MO. USA
    Beans
    214
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Automatically change processor settings when changing to/from battery on laptop

    Quote Originally Posted by erind View Post
    If you're using a command-line tool, such as cpufreq-set, to set manually the laptop's performance/conservative modes, then it's not that hard to implement such a script. If so, post that command(s) and the output of these commands:

    Code:
    find /proc/acpi/battery/ -ls
    
    find /sys/class/power_supply/
    
    ls -l /sys/class/power_supply/AC0/online
    Otherwise if you're using a GUI tool, it might not be that trivial, at least from my viewpoint.
    Here is the output of those commands:

    *******@Aquarius:~$ find /proc/acpi/battery/ -ls
    4026532068 0 dr-xr-xr-x 3 root root 0 Mar 30 20:35 /proc/acpi/battery/
    4026532069 0 dr-xr-xr-x 2 root root 0 Mar 30 20:35 /proc/acpi/battery/BAT1
    4026532072 0 -rw-r--r-- 1 root root 0 Mar 30 20:35 /proc/acpi/battery/BAT1/alarm
    4026532071 0 -r--r--r-- 1 root root 0 Mar 30 20:35 /proc/acpi/battery/BAT1/state
    4026532070 0 -r--r--r-- 1 root root 0 Mar 30 20:35 /proc/acpi/battery/BAT1/info
    *******@Aquarius:~$ find /sys/class/power_supply/
    /sys/class/power_supply/
    /sys/class/power_supply/ACAD
    /sys/class/power_supply/BAT1
    *******@Aquarius:~$ ls -l /sys/class/power_supply/AC0/online
    ls: cannot access /sys/class/power_supply/AC0/online: No such file or directory
    *******@Aquarius:~$

    Right now, I use CPU Frequency Scaling Monitor 2.30.0 in the gnome panel to adjust the frequency manually. I am running Ubuntu 10.04.

    Thanks,
    Neil

  4. #4
    Join Date
    Dec 2009
    Beans
    167

    Re: Automatically change processor settings when changing to/from battery on laptop

    It seems that online file is under ACAD directory. Can you run:

    Code:
    cat /sys/class/power_supply/ACAD/online
    Also in my script I use inotifywait and cpufreq-set, so just to make sure they are installed, run:

    Code:
    which inotifywait
    
    which cpufreq-set
    I'm gonna need the above output to modify the script.

  5. #5
    Join Date
    Feb 2011
    Location
    Somewhere...
    Beans
    1,557
    Distro
    Ubuntu 14.10 Utopic Unicorn

    Re: Automatically change processor settings when changing to/from battery on laptop

    There's an applet called Jupiter that automatically adjust settings like CPU, brightness, etc if you're on battery or on AC in order to conserve energy: http://jupiter.sourceforge.net/index.html

  6. #6
    Join Date
    Dec 2005
    Location
    Western Australia
    Beans
    11,480
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Automatically change processor settings when changing to/from battery on laptop

    OnDemand is usually the best CPU governor. Your CPU sleeps when there is nothing to do, then runs slowly when there is only a small load. When there is a large load, the CPU sprints, and then when the load drops it immediately goes back to sleep.

    Intel says it is more power efficient to run the CPU fast and complete its work quickly and make it sleep sooner, than it is to run it for longer at a slow pace. Intel also says that the performance gain by using the Performance governor (basically running the CPU at full speed all the time) is nearly immeasurably low.

    I don't know what software can change the governor on AC or battery (you could write a simple Bash script maybe?) but from what I understand your idea will hinder battery life, lower performance on battery and not help performance on mains power.
    I try to treat the cause, not the symptom. I avoid the terminal in instructions, unless it's easier or necessary. My instructions will work within the Ubuntu system, instead of breaking or subverting it. Those are the three guarantees to the helpee.

  7. #7
    Join Date
    Aug 2011
    Beans
    464
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Automatically change processor settings when changing to/from battery on laptop

    TLP from www.linrunner.de does that and more to save power, my power consumption with Ubuntu 12.04x64 went from 14W idle to 8W on my ASUS laptop with TLP installed and running on battery.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •