You are not logged in.

#1 2014-05-02 08:42:34

lviggiani
Member
Registered: 2014-02-28
Posts: 141

laptop-mode service does not activate if booting in battery mode

Hi, I have installed laptop-mode-tools like this:

$ yaourt -S laptop-mode-tools acpid bluez-utils wireless_tools cpupower
$ systemctl enable laptop-mode.service
$ systemctl enable acpid.service
$ systemctl enable cpupower.service
$ systemctl enable fancontrol
$ sensors-detect
$ systemctl enable lm_sensors.service

But if I boot the laptop with the AC adapter disconnected, laptop-mode service seems not activating: if I do "$ cat /proc/sys/vm/laptop_mode", I get "0" and also the battery discharges very quickly.

If I connect the AC adapter for a few seconds then disconnect it, or If I manually restart laptop-mode.service ($ systemctl restart laptop-mode.service), now "$ cat /proc/sys/vm/laptop_mode" gives "2" and battery lasts much longer.

It seems that laptop-mode service does not automatically recognize we are running on battery. Perhaps forcing it to start after acpid.service might help but I can't find how to do that...

Offline

#2 2014-05-12 16:02:51

ubuxav
Member
Registered: 2014-05-12
Posts: 1

Re: laptop-mode service does not activate if booting in battery mode

Hi,
I have exactly the same probleme. I am running ubuntu 14.04 on a dell vostro 3460.

When unplugin all is perfect, but when starting on battery no lapmodetools at work...

Offline

#3 2014-05-29 17:44:48

GSF1200S
Member
Registered: 2008-12-24
Posts: 474

Re: laptop-mode service does not activate if booting in battery mode

I also had the same problem; I would have to restart laptop-mode-tools with systemd before it would start working.

I never looked for a solution, and ended up switching to tlp (Im on a lenovo so tlp is great). You might file a bug report on this.

Alternatively, you could fix this with a bash script and a systemd service ran once at boot time if you wanted. For example, if you install acpi:

pacman -S acpi

then something like the following would work:

#!/bin/bash
if acpi | grep "discharging"; then
     systemctl restart laptop-mode-tools.service
fi

Then you just create a systemd service to launch this script at boot time (perhaps with a 5 or 10 second delay).

You can of course replace acpi with any custom scripts you have telling you whether the system runs on battery or AC currently, and change what grep looks for from that output accordingly. So if program "foo" outputs "system on the battery" when on battery and "system running off the wall" when on AC, your script might look like:

#!/bin/bash
if foo | grep "battery"; then
      systemctl restart laptop-mode-tools.service
fi

The systemd service should be of type oneshot and youll prolly want to delay it a few seconds so the program which monitors battery state is loaded.

Offline

#4 2014-05-29 20:39:58

lviggiani
Member
Registered: 2014-02-28
Posts: 141

Re: laptop-mode service does not activate if booting in battery mode

hi thanks for your hint about tlp. Just removed laptop-mode-tools and installed tlp and tlp-rdw as per ArchWiki. It seems to work fine!


GSF1200S wrote:

I also had the same problem; I would have to restart laptop-mode-tools with systemd before it would start working.

I never looked for a solution, and ended up switching to tlp (Im on a lenovo so tlp is great). You might file a bug report on this.

Alternatively, you could fix this with a bash script and a systemd service ran once at boot time if you wanted. For example, if you install acpi:

pacman -S acpi

then something like the following would work:

#!/bin/bash
if acpi | grep "discharging"; then
     systemctl restart laptop-mode-tools.service
fi

Then you just create a systemd service to launch this script at boot time (perhaps with a 5 or 10 second delay).

You can of course replace acpi with any custom scripts you have telling you whether the system runs on battery or AC currently, and change what grep looks for from that output accordingly. So if program "foo" outputs "system on the battery" when on battery and "system running off the wall" when on AC, your script might look like:

#!/bin/bash
if foo | grep "battery"; then
      systemctl restart laptop-mode-tools.service
fi

The systemd service should be of type oneshot and youll prolly want to delay it a few seconds so the program which monitors battery state is loaded.

Offline

Board footer

Powered by FluxBB