Laptop power management

Archived topics about LMDE 1 and LMDE 2
Locked
Motion

Laptop power management

Post by Motion »

Hi !

I have a little hitch but I am pretty sure it won't last.

As I am working on a laptop, which package should I install, which integrates perfectly with cinnamon and enables the laptop to enter the sleep mode when running out of battery ?

Currently, it is shutting it off, which is *really, really* annoying.

Please, let me know !

Thanks,

Motion
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
FDF

Re: Laptop power management

Post by FDF »

Hi,

Which laptop? please give as much details as possible to allow us to find out your equipment…
Motion

Re: Laptop power management

Post by Motion »

Hi !

I own a macbook (white).

2.16ghz. 2007.

When I am running out of batterey, it shuts down instead of sleeping.

I lost my works sometimes, so it is pretty annoying..

Let me know if you need further information !

Regards,

Motion
jasmineaura

Re: Laptop power management

Post by jasmineaura »

Check your settings in:
Control Center -> Hardware -> Power management
"On battery power" and "General tab".

By default, pm-utils package is installed and should take care of that.
# dpkg -l pm-utils
ii pm-utils 1.4.1-9 utilities and scripts for power management

# apt-cache show pm-utils
...
Description-en: utilities and scripts for power management
This package provides simple shell command line tools to suspend and
hibernate your computer.
Homepage: http://pm-utils.freedesktop.org/
...
You may also want to look at the "laptop-mode-tools" package:
# apt-cache show laptop-mode-tools
...
Description-en: Tools for Power Savings based on battery/AC status
Laptop mode is a Linux kernel feature that allows your laptop to save
considerable power, by allowing the hard drive to spin down for longer
periods of time. This package contains the userland scripts that are
needed to enable laptop mode.
.
It includes support for automatically enabling laptop mode when the
computer is working on batteries. It also supports various other power
management features, such as starting and stopping daemons depending on
power mode, automatically hibernating if battery levels are too low, and
adjusting terminal blanking and X11 screen blanking
.
laptop-mode-tools uses the Linux kernel's Laptop Mode feature and thus
is also used on Desktops and Servers to conserve power
Homepage: http://www.samwel.tk/laptop_mode/
...
Keep in mind that modules (or rather scripts) from laptop-mode-tools can conflict with others from pm-utils. Example: laptop mode wouldn't disable once AC connected, as it normally should. This can be fixed by disabling scripts with duplicate functionality in pm-utils.
The main cause of this is the "laptop-mode" script located in "/usr/lib/pm-utils/power.d".

To disable a script from /usr/lib/pm-utils/power.d/ simply create an empty file in /etc/pm/power.d/ with the same name and without the execute bit set

Alternatively, the script can be blacklisted by creating a file in /etc/pm/config.d as follows:
$ sudo gedit /etc/pm/config.d/01_blacklist (You can call it whatever else you want)

Code: Select all

HOOK_BLACKLIST="laptop-mode"
You can also add any other scripts found in /usr/lib/pm-utils/power.d to this list to disable them.

More info on pm-utils and laptop-mode-tools:
https://help.ubuntu.com/community/Power ... ducedPower
https://wiki.archlinux.org/index.php/Pm-utils
https://wiki.archlinux.org/index.php/Laptop_Mode_Tools
(though articles from ubuntu/archlinux, most of it is no different from doing it on Linux Mint / Debian)

Basic packages that were auto-installed in my case (maybe except for powertop)
# dpkg -l *power* | grep ^ii
ii gir1.2-upowerglib-1.0 0.9.17-1 GObject introspection data for upower
ii gnome-power-manager 3.4.0-2 power management tool for the GNOME desktop
ii libupower-glib1 0.9.17-1 abstraction for power management - shared library
ii mate-power-manager 1.4.0-1+wheezy power management tool for the MATE desktop
ii mate-power-manager-common 1.4.0-1+wheezy power management tool for the MATE desktop (common files)
ii powermgmt-base 1.31 Common utils and configs for power management
ii powertop 2.0-0.2 Linux tool to find out what is using power on a laptop
ii upower 0.9.17-1 abstraction for power management

# apt-cache search power-manager
mate-power-manager - power management tool for the MATE desktop
mate-power-manager-common - power management tool for the MATE desktop (common files)
mate-power-manager-dbg - power management tool for the MATE desktop (debugging symbols)
gnome-power-manager - power management tool for the GNOME desktop
xfce4-goodies - enhancements for the Xfce4 Desktop Environment
xfce4-power-manager - power manager for Xfce desktop
xfce4-power-manager-data - power manager for Xfce desktop, arch-indep files
xfce4-power-manager-plugins - power manager plugins for Xfce panel
Motion

Re: Laptop power management

Post by Motion »

Jasmine,

Many thanks, I missed powertop. We will see if it changes anything !

Every day passing, my love is growing for this distribution.

See you !
jasmineaura

Re: Laptop power management

Post by jasmineaura »

Motion,

Powertop doesn't manage anything. It's name is akin to "top", a popular command-line tool to monitor top processes based on various usage variables (CPU/MEM/SWAP etc.). So all powertop really does is show you which processes generate "wake-up calls" -- what keeps CPU and/or Disks busy, and prevents them from idling to save power, along with educated-guessing of which processes/devices use most power. The more reliable method of using powertop is to run it after you've pulled the plug, to see actual battery drain rates, and power usage fluctuations as you use the comptuer, or just let it idle.
Recent versions (2.0) have a tabbed interface with the last tab being "Tunables" where powertop suggests some things to do in order to achieve less power usage. They can be toggled with the press of a key -- enter. This can be handy for further tuning power usage, but not all actually make a difference or help (depends on feature, and/or your hardware/software/kernel-version). The changes made via the Tunables tab are not permanent, meaning they're lost upon reboot. One could get a report of what it suggests (along with all other info) in HTML by running `powertop --html=/home/me/Documents/` (it will automatically create powertop-xxxxx.html file in the location you specify). The generated html report is also tabbed (provided you're using an HTML5 capable browser), and there you can click the Tunables tab as well and see all the same recommendations it gives, along with the associated commands to reach those ends (which is not shown in the standard command line interface).

So, briefly, if your laptop shuts down when on battery, then it must be one of the following:
1. Battery drained completely (no more charge left) and so the system literally lost power; bad shutdown. This could mean power-manager of your Desktop Environment (DE) isn't running. Ex. mate-power-manager, gnome-power-manager, xfce-power-manager, etc. Check your DE's "startup applications" (usually under preferences) and make sure one (and only one) of those is checked. If you're running alternate/custom setup, make sure to pick one you like and add it to your DE's startup list, or in .xinitrc in your home directory

2. Battery reached critical level, your DE's power manager got the signal notification from ACPI, and so it immediately decided to shutdown. This is *clean* shutdown, as opposed to *bad* shutdown caused by power-out as in #1. In this case, it is a matter of configuring your DE's power-manager to choose what happens when battery reaches critical battery level; recommended: hibernate, as opposed to suspend will still draw small amounts of battery power overtime.

3. You, the user, were idle (no keyboard/mouse/touchpad activity) and no programs were running or accessing the disk and the DE's power manager decided to shutdown the computer. This is unlikely, as defaults of the DE power managers in this case (idle timeout) are either suspend or hibernate.

So , if you're still having that issue and cannot figure it out, do tell which Desktop environment you're using when the shutdown happens, and whether it is bad shutdown (Battery drained completely), or clean shutdown (issued by some program). You can tell when you power-on your computer again, during bootup (or via `dmesg` after boot) to see warnings such as "filesystem was not cleanly unmounted on shutdown".

You can use a tool like "caffeine" to keep the computer active while on battery to drain it down completely, to once again see what happens then -- clean shutdown on critical level, or bad shutdown when it runs out.

Cheers
Motion

Re: Laptop power management

Post by Motion »

Jasmine,

THAT is an explanation ! You are kind.

I currently use Cinnamon. Maybe my hitch is related to this.

But again thanks for your clarifications, there are really appreciated here.

Cheers
jasmineaura

Re: Laptop power management

Post by jasmineaura »

One last note, while I'm still working on PM stuff and everything's fresh.

/usr/lib/pm-utils/defaults says:

Code: Select all

# Check /sys/power/disk for valid values.  The default value
# will be surrounded by [square brackets].
# HIBERNATE_MODE="shutdown"
Mine looks like this:
# cat /sys/power/disk
[platform] shutdown reboot
If yours has the square brackets around [ shutdown ], you need to:

Code: Select all

echo 'HIBERNATE_MODE="platform"' | sudo tee /etc/pm/config.d/defaults
Motion

Re: Laptop power management

Post by Motion »

Mine says :

Code: Select all

 [platform] test testproc shutdown reboot 
I don't know if it changes anything though..
Locked

Return to “LMDE Archive”