# how to configure laptop-mode?

## pd1986

hello

I tried to configure laptop-mode by following the Gentoo Power management guide and the man page. But it doesn't work. I don't where I am wrong. Please figure it out for me. Thanks in advance.

Here is the details

objective: change the cpu governor and lcd brightness automatically as laptop plugged or unplugged

Problem:

at first, I have to say that I can change it manually by, for example, "cpufreq-set -c 0 -g ondemand" for cpu frequency and "echo 4 > /sys/class/thermal/cooling_device0/cur_state"(which is to control LCD brightness)

For cpu frequency modulation, I modified file "/etc/laptop-mode/conf.d/cpufreq.conf" as follows

 *Quote:*   

> 31 # Should laptop mode tools control the CPU frequency settings?
> 
> 32 #
> 
> 33 # Set to 0 to disable
> ...

 

As the same as that before, for LCD brightness, I modified file "/etc/laptop-mode/conf.d/lcd-brightness.conf" as follows

 *Quote:*   

> 61 BATT_BRIGHTNESS_COMMAND="echo 4"
> 
> 62 LM_AC_BRIGHTNESS_COMMAND="echo 1"
> 
> 63 NOLM_AC_BRIGHTNESS_COMMAND="echo 0"
> ...

 

Then, when I unplugged the AC adapter, I can see that the laptop_mode is switched on from off by 

 *Quote:*   

> laptop_mode

 

but the cpufrequency governor and the LCD brightness weren't changed.

Here is the details of configuration file 

"/etc/laptop-mode/laptop-mode.conf"

 *Quote:*   

> 
> 
> ENABLE_LAPTOP_MODE_TOOLS=1
> 
> VERBOSE_OUTPUT=0
> ...

 

"/etc/laptop-mode/conf.d/cpufreq.conf"

 *Quote:*   

> DEBUG=0
> 
> CONTROL_CPU_FREQUENCY="auto"
> 
> BATT_CPU_MAXFREQ=fastest
> ...

 

"/etc/laptop-mode/conf.d/lcd-brightness.conf"

 *Quote:*   

> 
> 
> DEBUG=0
> 
> CONTROL_BRIGHTNESS=1
> ...

 

----------

## pd1986

Sorry for forgetting to point you the environment

kernel: 3.2.12-gentoo

desktop: xfce4

----------

## pd1986

still unsolved, need help. please

----------

## Nicias

What does 

```
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors 
```

 return?

----------

## pd1986

 *Nicias wrote:*   

> What does 
> 
> ```
> cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors 
> ```
> ...

 

it returns all the available governors

conservative ondemand powersave userspace performance

I can convert governor among these options manually.

----------

## Nicias

I just looked around my system, and I control my cpu via cpufrequtils. I have this in my /etc/laptop-mode/conf.d/start-stop-programs.conf

```

....

#

# Should laptop mode start and stop programs? 

#

CONTROL_START_STOP=1

#

# Services to start/stop depending on the power state.

#

#

# These services are started/stopped through their init scripts, together with

# the files from the directories mentioned above. Specify the services as a

# space separated list.

#

BATT_STOP="cpufrequtils sshd ntpd fcron"

BATT_START="lcd-dim"

LM_AC_STOP="lcd-dim"

LM_AC_START="cpufequtils sshd ntpd fcron"

NOLM_AC_STOP=""

NOLM_AC_START=""
```

Then in /etc/conf.d/cpufrequitls I have 

```
# /etc/conf.d/cpufrequtils: config file for /etc/init.d/cpufrequtils

# Options when starting cpufreq (given to the `cpufreq-set` program)

START_OPTS="--governor conservative"

# Options when stopping cpufreq (given to the `cpufreq-set` program)

STOP_OPTS="--governor powersave"
```

lcd-dim is an init script I wrote myself:

```
#!/sbin/runscript

start() {

        ebegin "Setting LCD brightness"

        setpci -s 00:02.0 F4.B=${INTEL_DIM}

        eend $?

}

stop () {

        ebegin "Setting LCD brightness"

        setpci -s 00:02.0 F4.B=${INTEL_NORMAL}

        eend $?

}
```

with /etc/conf.d/lcd-dim

```

# brightness level in ac mode. Default is 7. (intel is in hex)

INTEL_NORMAL=ff

# brightness level in battery mode. Default is 4. (intel is in hex.)

INTEL_DIM=10

```

I'm calling it "INTEL" since I used to have a complicated scheme to deal with my hybrid graphics, but bumblebee has sorted that out.

cpufrequtils,  sshd, fcron, and ntpd are in the default runlevel.

Come to think of it, I should remove sshd from the whole thing I don't need to run it that often.

----------

## pd1986

 *Nicias wrote:*   

> I just looked around my system, and I control my cpu via cpufrequtils. I have this in my /etc/laptop-mode/conf.d/start-stop-programs.conf
> 
> ```
> 
> ....
> ...

 

You mean that I need to start these script by this?

 *Quote:*   

> BATT_STOP="cpufrequtils sshd ntpd fcron"
> 
> BATT_START="lcd-dim"
> 
> LM_AC_STOP="lcd-dim"
> ...

 

I don't this kind of configuration, every cmd is empty. this is mine

 *Quote:*   

> BATT_STOP=""
> 
> BATT_START=""
> 
> LM_AC_STOP=""
> ...

 

I don't think the problem comes from there

However, does the configuration file in /etc/laptop-mode/con.f/ work automatically? like lcd-brightness.conf, cpufreq.conf.

is it enought if I have

 *Quote:*   

> ENABLE_AUTO_MODULES=1

 

in laptop-mode.conf?

----------

## Nicias

I'm not using the configuration in /etc/laptop-mode/conf.d/ so don't know if and how well they work. I have laptop mode offload most of it's configuration to services, so I can override them if I want. For example, if I want to use my full speed cpu, I can start cpufrequtils by hand, and then I'm good to go.

I'm suggesting if you are having trouble with laptop mode managing your cpu governer, have it control the cpufrequtils service instead. So comment out your /etc/laptop-mode/conf.d/cpufreq.conf. Add cpufreq to line lines in /etc/laptop-mode/conf.d/start-stop-programs.conf  where I have it, and configure your /etc/conf.d/cpufrequtils

----------

## pd1986

 *Nicias wrote:*   

> I'm not using the configuration in /etc/laptop-mode/conf.d/ so don't know if and how well they work. I have laptop mode offload most of it's configuration to services, so I can override them if I want. For example, if I want to use my full speed cpu, I can start cpufrequtils by hand, and then I'm good to go.
> 
> I'm suggesting if you are having trouble with laptop mode managing your cpu governer, have it control the cpufrequtils service instead. So comment out your /etc/laptop-mode/conf.d/cpufreq.conf. Add cpufreq to line lines in /etc/laptop-mode/conf.d/start-stop-programs.conf  where I have it, and configure your /etc/conf.d/cpufrequtils

 

Thanks, I will do the same.

----------

## Nicias

Great, let me know how it goes.

----------

## pd1986

 *Nicias wrote:*   

> Great, let me know how it goes.

 

In fact, cpufrequtils starts when the system boots. So I just wrote a script file (not service) to control the cpufreq and lcd brightness, but in this case, it seems there is no interest in using laptop-mode.

In addition, do you know what to do to make laptop last longer in using battery besides decreasing lcd brightness and change the cpu frequency governor? I heard of hdparm to control hard disk which is included in laptop-mode, but I don't if laptop-mode can do it well. That's also why I want to know how to configure laptop-mode to make it work well.

I also use powertop to see which program consume the most. I find three ones, swapper/0, swapper/1 and kworker/0:3. They use more than 60% of total power. I don't know what they are. Do you have some ideas?

Thanks.

----------

## Nicias

laptop mode can control things like how long the kernel will keep writes cached before spinning up the drive, stuff like that. If I had to guess swapper0 and swapper1 sound like you are hitting swap on your laptop. What does "free -m" report?

----------

## pd1986

 *Nicias wrote:*   

> laptop mode can control things like how long the kernel will keep writes cached before spinning up the drive, stuff like that. If I had to guess swapper0 and swapper1 sound like you are hitting swap on your laptop. What does "free -m" report?

 

I am sorry, I don't understand what you said about the laptop-mode control

yes I have swap partition in my laptop, does just swap consume more battery? I mean, in windows7 the duration of use under battery shows 3h30, but in linux, (I use xfce4), the monitor shows only 2h20. I don't understant.

for free -m

 *Quote:*   

>              total       used       free     shared    buffers     cached
> 
> Mem:          2002       1717        285          0        281        558
> 
> -/+ buffers/cache:        876       1125
> ...

 

----------

## Nicias

I just edited some of the options in /etc/laptop-mode/laptop-mode.conf. Some of them have to do with how the harddrive is used. 

No, just having swap available does not decrease battery life, but if it actually getting used, then it does. Looking at the results of "free" it appears that your available swap isn't being used at all. Which is good. Note the 0 in the Swap/used category. 

I'm in over my head in terms of battery time. My method is:

 Dim LCD

 Turn off services (cron, ntp, etc)

 Turn on laptop-mode

 Follow all the suggestions powertop makes.

That is the limit of my expertise.

----------

## pd1986

 *Nicias wrote:*   

> I just edited some of the options in /etc/laptop-mode/laptop-mode.conf. Some of them have to do with how the harddrive is used. 
> 
> No, just having swap available does not decrease battery life, but if it actually getting used, then it does. Looking at the results of "free" it appears that your available swap isn't being used at all. Which is good. Note the 0 in the Swap/used category. 
> 
> I'm in over my head in terms of battery time. My method is:
> ...

 

Thanks, but powertop doesn't find my acpi setting for power usage, here is the info from powertop

 *Quote:*   

> ......
> 
> no ACPI power usage estimate available
> 
> ......
> ...

 

I am always struggling with my acpi working because my fan doesn't work perfectly.

----------

## Nicias

That sounds like an error in your kernel config.

----------

## pd1986

 *Nicias wrote:*   

> That sounds like an error in your kernel config.

 

I think so but I haven't figure it out.

No matter I compile the kernel by "genkernel" or manually, the fan problem is always there.

----------

## Nicias

If it helps, here is my kernel config

http://pastebin.ca/2144806

----------

## pd1986

 *Nicias wrote:*   

> If it helps, here is my kernel config
> 
> http://pastebin.ca/2144806

 

Thanks a lot

----------

