Power Saving on laptops

Hi

I think power saving on linux laptops is something of a rabbit hole. Before I dive down the rabbit hole, I want to know if anyone has any suggestions that can save me some time on research.

SO what I would like to solve is battery time on my laptop, and looking for it to perform as well as possible.
The laptop also gets a little warm from time to time. But here I think I have to look at CPU frequency scaling and fan speed.

I have approx. 4-6 hours of battery time on my laptop depending on what I use it for.

Iā€™m a little unsure about what I should use for power saving.

What I, among other things, would like to achieve is that my laptop automatically goes into suspend if no buttons have been pressed for more than 15 min, unless Iā€™m watching a video.
If possible, I would also like to set my laptop to automatic hypernet if there is 5% battery left.

How should I approach this?

Powertop? Laptop Mode Tools, manual configuration or something else entirely?
Maybe there is a power saving profile that comes with one of the other EOS spins I could use?

As I write, itā€™s a bit of a rabbit hole. Where should I start?

Should I start with powertop, Laptop Mode Tools or powersaving profile from another EOS spin?

I really want to avoid scripting the hell out of my laptop.

Hardware info:

sudo inxi -Fxmz

System:
  Kernel: 6.0.11-zen1-1-zen arch: x86_64 bits: 64 compiler: gcc v: 12.2.0
    Desktop: dwm v: 6.4 Distro: EndeavourOS base: Arch Linux
Machine:
  Type: Laptop System: Dell product: XPS 13 9300 v: N/A serial: <filter>
  Mobo: Dell model: 077Y9N v: A00 serial: <filter> UEFI: Dell v: 1.15.0
    date: 09/13/2022
Battery:
  ID-1: BAT0 charge: 38.6 Wh (100.0%) condition: 38.6/51.0 Wh (75.7%)
    volts: 8.5 min: 7.6 model: SMP DELL WN0N00B status: full
Memory:
  RAM: total: 15.21 GiB used: 5.61 GiB (36.9%)
  Array-1: capacity: 16 GiB slots: 2 EC: None max-module-size: 8 GiB
    note: est.
  Device-1: Motherboard type: LPDDR4 size: 8 GiB speed: spec: 4267 MT/s
    actual: 3733 MT/s
  Device-2: Motherboard type: LPDDR4 size: 8 GiB speed: spec: 4267 MT/s
    actual: 3733 MT/s
CPU:
  Info: quad core model: Intel Core i7-1065G7 bits: 64 type: MT MCP
    arch: Ice Lake rev: 5 cache: L1: 320 KiB L2: 2 MiB L3: 8 MiB
  Speed (MHz): avg: 1068 high: 1500 min/max: 400/3900 cores: 1: 400 2: 916
    3: 1201 4: 1500 5: 1130 6: 1500 7: 1500 8: 400 bogomips: 23961
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
Graphics:
  Device-1: Intel Iris Plus Graphics G7 vendor: Dell driver: i915 v: kernel
    arch: Gen-11 bus-ID: 00:02.0
  Device-2: Realtek Integrated_Webcam_HD type: USB driver: uvcvideo
    bus-ID: 3-9:2
  Display: server: X.Org v: 21.1.4 driver: X: loaded: modesetting
    unloaded: fbdev dri: iris gpu: i915 resolution: 3840x2400~60Hz
  API: OpenGL v: 4.6 Mesa 22.2.3 renderer: Mesa Intel Iris Plus Graphics
    (ICL GT2) direct render: Yes
Audio:
  Device-1: Intel Ice Lake-LP Smart Sound Audio vendor: Dell
    driver: snd_hda_intel v: kernel bus-ID: 00:1f.3
  Sound API: ALSA v: k6.0.11-zen1-1-zen running: yes
  Sound Server-1: PulseAudio v: 16.1 running: no
  Sound Server-2: PipeWire v: 0.3.61 running: yes
Network:
  Device-1: Intel Ice Lake-LP PCH CNVi WiFi vendor: Rivet Networks
    driver: iwlwifi v: kernel bus-ID: 00:14.3
  IF: wlan0 state: up mac: <filter>
Bluetooth:
  Device-1: Intel AX201 Bluetooth type: USB driver: btusb v: 0.8
    bus-ID: 3-10:3
  Report: rfkill ID: hci0 rfk-id: 0 state: up address: see --recommends
Drives:
  Local Storage: total: 953.87 GiB used: 6.09 GiB (0.6%)
  ID-1: /dev/nvme0n1 vendor: KIOXIA model: KXG60ZNV1T02 NVMe 1024GB
    size: 953.87 GiB temp: 50.9 C
Partition:
  ID-1: / size: 205.47 GiB used: 5.97 GiB (2.9%) fs: btrfs dev: /dev/nvme0n1p9
  ID-2: /boot/efi size: 346.9 MiB used: 122.3 MiB (35.2%) fs: vfat
    dev: /dev/nvme0n1p1
  ID-3: /home size: 205.47 GiB used: 5.97 GiB (2.9%) fs: btrfs
    dev: /dev/nvme0n1p9
  ID-4: /var/log size: 205.47 GiB used: 5.97 GiB (2.9%) fs: btrfs
    dev: /dev/nvme0n1p9
Swap:
  ID-1: swap-1 type: partition size: 25 GiB used: 0 KiB (0.0%)
    dev: /dev/nvme0n1p8
Sensors:
  System Temperatures: cpu: 62.0 C mobo: 51.0 C
  Fan Speeds (RPM): cpu: 5401 mobo: 5100
Info:
  Processes: 257 Uptime: 6h 36m Init: systemd Compilers: gcc: 12.2.0
  Packages: 853 Shell: Zsh v: 5.9 inxi: 3.3.23

dependeing on when you have installed EndeavourOS you will have power-profiles-daemon running already, and it should do a good job on intel CPUs.

systemctl status power-profiles-daemon will tell if it is running
It has 3 profiles you can set from settings on GNOME and from command line too or use this:

https://raw.githubusercontent.com/endeavouros-team/PKGBUILDS/master/power-profiles-switcher/PKGBUILD

I find this to be of some interest in terms of being fully charged yet at only 38Wh out of 51Wh. Does your battery generally perform well, or might it be getting a bit old - perhaps suggesting itā€™s time for a replacement? :thinking:

EDIT: Upon further research, itā€™s unlikely youā€™ve got an aging battery given the recent production of these Dell laptops. Sorry if I unduly alarmed you!

It is well seen.
But mine is 2 years old. But it should still be able to perform a little better than what it can do right now.

My windows laptop with older battery out performs this dell laptop. And on Windows, it runs longer and gets less or not hot at all.

Perfect and thank you, it is already installed.

I canā€™t find the package you refer to through pacman or yay.

Do you know how to configure it from the command line? And is there a way I can see what kind of power saving settings are in it?

the switcher tool is something i wrote some times ago ā€¦ you need to build on your ownā€¦ we still not have it in the repo.

download the PKGBUILD save it in a folder called power-profiles-switcher open a terminal there and build with makepkg -si

Ok, thanks.
Iā€™ll try it and see how it works. And really cool with small applications that can do small things.
I think it is too excessive if everything has to be done through a terminal, or a script that is tied to a keybinding or something like that.

yes need sto be easy to switch I have set this on the panel for i3 setupā€¦ but there is no such tool for most DEā€™s so idea was to have something generically working ā€¦

But as I do not have intel CPU and do not use ppd here I can not really test the app :wink:

So if someone use it I am happy for feedbackā€¦

It works fine. Itā€™s super minimal and it does exactly what itā€™s supposed to do.
I use dwm. And the text in floating mode, was very close to each other. I made it a little bigger than the size it pops up in as default. And it was absolutely perfect. I donā€™t know if itā€™s because Iā€™m using a wm and not a DE since the text was very close together.

I think that many of those who use a DE would like it if there were some graphics that showed some kind of performance graph.

In the meantime, thanks to your script, I figured out how to use the power profile settings.
It calls powerprofilesctl. I really should find out what is in my bin folder and what they belong to.

Do you have any dot files where I can see how you have set it up in your i3 panel?
I use dwm and dwmblocks as a status bar. I use dmenu to call different applications. It could be cool if it could be integrated into my status bar, like e.g. nm-applet. But I should be able to make a script that shows info about what power saving mode it is in and a clickeble script to switch modes.

  1. https://github.com/endeavouros-team/endeavouros-i3wm-setup/blob/89c01292d075f1e535e70719387d6499c82ae59a/.config/i3/i3blocks.conf#L153

  2. https://github.com/endeavouros-team/endeavouros-i3wm-setup/blob/main/.config/i3/scripts/power-profiles

  3. https://github.com/endeavouros-team/endeavouros-i3wm-setup/blob/main/.config/i3/scripts/ppd-status

I have a little more feedback about ppd-switcher.

When i open ppd-switcher, at the top it says what the current profile is.

But the drop down menu is always on Balanced. Itā€™s confusing because itā€™s the first thing you notice when you open ppd-switcher.
It will make it less confusing if it was not on Balanced as default, but e.g. something like choose a profile, or something like that.

yes i see the same but as it is a very simple yad GUI there are not much options ā€¦ i will check about this ā€¦ may @manuel knows something he is the yad king :crown:

2022-12-07_16-44
2022-12-07_16-44_1
this would be better?

I forgot to mention that I think this power-profiles-daemon, It works fine. It sets my cpu speed down or up depending on what profile I choose.

But there is still not much battery time left.

I donā€™t think there is much more that can be done. Other than perhaps somehow setting it up to suspend if no buttons are pressed, and a screen saver and a screen locker.
I know how to set up the latter, but I donā€™t know how to set timers for suspend and hibernate, and how to make a rule so that it doesnā€™t start to go into suspend or hibernate while Iā€™m watching a video.

this would be better?

Yes, much better. Let me know when I can download the new file.

I was just about to try and change it myself to see if my idea worked.

I assume you have added one more option like below:

action=$(yad --width 310 --window-icon=gnome-power-manager --entry --title "Power Profile Switcher" \
    --image=gnome-power-manager \
    --button="ļ˜ Switch:0" --button="ļž Quit" \
    --text "Currently using: $get \ Change to your preferred profile:" \
    --entry-text \
    "change profile here" "ļ‰Ž Balanced" "ļŠ™ Power-Saver" "ļƒ§ Performance")
ret=$?

yes added an option in front so it shows that ā€¦

#! /bin/bash

get=$(powerprofilesctl get)-profile

action=$(yad --width 310 --window-icon=gnome-power-manager --entry --title "Power Profile Switcher" \
    --image=gnome-power-manager \
    --button="ļ˜ Switch:0" --button="ļž Quit" \
    --text "Currently using: $get \ Change to your preferred profile:" \
    --entry-text \
   "ļ€” change profile here:" "ļ‰Ž Balanced" "ļŠ™ Power-Saver" "ļƒ§ Performance")
ret=$?

[[ $ret -eq 1 ]] && exit 0

if [[ $ret -eq 2 ]]; then
    gdmflexiserver --startnew &
    exit 0
fi

case $action in
    ļ‰Ž*) cmd="powerprofilesctl set balanced & notify-send -t 5000 -i power-profile-balanced-symbolic 'Switched to ba>
    ļŠ™*) cmd="powerprofilesctl set power-saver & notify-send -t 5000  -i power-profile-power-saver-symbolic 'Switche>
    ļƒ§*) cmd="powerprofilesctl set performance & notify-send -t 5000 -i power-profile-performance-symbolic 'Switched>
    *) exit 1 ;;
esac

eval exec $cmd
1 Like

it is a known issue that linux is sucking more energy as machines are only optimized for using windows ā€¦ not like on server hardware :wink: ā€¦

And yes setting up sleep suspend hibernate is a good option.
I do use close lid ā†’ suspend on my notebook as I do not use it very often it is mainly my internet portal in the kitchen ā€¦ so I simpĆ¼ly close it and it suspends to wake up fast when I need itā€¦

ppd has only profiles and nothing to fine-tune power consumptionā€¦ it will not power down wifi as far as I knowā€¦ some devices do this per default but wifi and display are the two things using a lot of powerā€¦

yes, on linux, I can almost always hear the cpu fans running, and my laptop also gets hot.

On windows I canā€™t hear the fan at all and it doesnā€™t get hot.

The hardwear behave differently on linux.

in cases there are options and tools that can helpā€¦ like osi boot parameter:
https://discovery.endeavouros.com/acpi-kernel-parameters/acpi-kernel-parameters-and-how-to-choose-them/2021/03/

1 Like

I forgot to say thank you.

But it didnā€™t really help, it keeps getting hot. But I think thanks to your link, I will look more into ACPI

As the person who made the guide writes, it is a small insight into ACPI. I try to go further down the rabbit hole as soon as I finish my grub setup.

1 Like