2

I'm trying to conserve my new laptop's battery for many years to come. Can you help me set this up optimally (probably a way to have it automatically stop charging the battery after it reaches some value between 60 to 85%)?

I have read a fair bit about tlp, tp-smapi, and tpacti-bat online, but end up being more confused about it than understanding which one is best for a newer machine (most posts and comments I've read are ~8 years old); and how to install and configure the battery with whichever one is best.

Thank you in advance! Here is information regarding my setup :-)

  • OS: Ubuntu 24.04 LTS
  • Model: Lenovo ThinkPad X13 Gen 4
  • Processor: AMD Ryzen™ 7 PRO 7840U
  • Kernal: Linux 6.8.0-31-generic

(It's probably unnecessary, but in the terminal, the command lsmod yields:

...:~$ lsmod

Module Size Used by

ccm 20480 6

michael_mic 12288 1

rfcomm 98304 4

snd_seq_dummy 12288 0

snd_hrtimer 12288 1

snd_seq_midi 24576 0

snd_seq_midi_event 16384 1 snd_seq_midi

snd_rawmidi 57344 1 snd_seq_midi

snd_seq 118784 9 snd_seq_midi,snd_seq_midi_event,snd_seq_dummy

snd_seq_device 16384 3 snd_seq,snd_seq_midi,snd_rawmidi

cmac 12288 3

algif_hash 12288 1

algif_skcipher 16384 1

af_alg 32768 6 algif_hash,algif_skcipher

bnep 32768 2

qrtr_mhi 16384 0

binfmt_misc 24576 1

nls_iso8859_1 12288 2

amdgpu 17088512 9

snd_acp6x_pdm_dma 12288 0

snd_soc_dmic 12288 0

snd_soc_acp6x_mach 28672 0

snd_sof_amd_acp63 16384 0

snd_sof_amd_vangogh 16384 0

snd_sof_amd_rembrandt 16384 0

snd_sof_amd_renoir 16384 0

snd_sof_amd_acp 61440 4

snd_sof_amd_rembrandt,snd_sof_amd_vangogh,snd_sof_amd_acp63,snd_sof_amd _renoir

snd_sof_pci 24576 4 snd_sof_amd_rembrandt,snd_sof_amd_vangogh,snd_sof_amd_acp63,snd_sof_amd_renoir

snd_sof_xtensa_dsp 12288 1 snd_sof_amd_acp

snd_sof 380928 2 snd_sof_amd_acp,snd_sof_pci

snd_ctl_led 24576 0

snd_sof_utils 16384 1 snd_sof

snd_hda_codec_realtek 200704 1

snd_soc_core 454656 4 snd_soc_acp6x_mach,snd_sof,snd_acp6x_pdm_dma,snd_soc_dmic

snd_hda_codec_generic 122880 1 snd_hda_codec_realtek

snd_compress 28672 1 snd_soc_core

snd_hda_codec_hdmi 94208 1

amdxcp 12288 1 amdgpu

btusb 77824 0

ac97_bus 12288 1 snd_soc_core

drm_exec 16384 1 amdgpu

btrtl 36864 1 btusb

snd_pcm_dmaengine 16384 1 snd_soc_core

gpu_sched 61440 1 amdgpu

snd_pci_ps 24576 0

snd_hda_intel 61440 2

uvcvideo 139264 0

btintel 57344 1 btusb

drm_buddy 20480 1 amdgpu

snd_rpl_pci_acp6x 16384 0

snd_intel_dspcfg 36864 2 snd_hda_intel,snd_sof

videobuf2_vmalloc 20480 1 uvcvideo

btbcm 24576 1 btusb

drm_suballoc_helper 16384 1 amdgpu

snd_acp_pci 12288 0

snd_intel_sdw_acpi 16384 1 snd_intel_dspcfg

uvc 12288 1 uvcvideo

btmtk 16384 1 btusb

drm_ttm_helper 12288 1 amdgpu

snd_acp_legacy_common 16384 1 snd_acp_pci

videobuf2_memops 16384 1 videobuf2_vmalloc

snd_hda_codec 217088 4 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec_re altek

ttm 110592 2 amdgpu,drm_ttm_helper

videobuf2_v4l2 40960 1 uvcvideo

bluetooth 1089536 34 btrtl,btmtk,btintel,btbcm,bnep,btusb,rfcomm

snd_pci_acp6x 16384 0

snd_hda_core 151552 5 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,sn d_hda_codec_realtek

drm_display_helper 253952 1 amdgpu

snd_pci_acp5x 16384 0

videodev 364544 2 videobuf2_v4l2,uvcvideo

snd_hwdep 20480 1 snd_hda_codec

cec 98304 1 drm_display_helper

snd_rn_pci_acp3x 16384 0

ecdh_generic 16384 2 bluetooth

videobuf2_common 86016 4 videobuf2_vmalloc,videobuf2_v4l2,uvcvideo,videobuf2_memops

snd_acp_config 20480 9 snd_rn_pci_acp3x,snd_pci_acp6x,snd_pci_acp5x,snd_sof_amd_rembrandt,snd_ sof_amd_vangogh,snd_sof_amd_acp63,snd_acp_pci,snd_pci_ps,snd_sof_amd_re noir

rc_core 77824 1 cec

snd_pcm 200704 13 snd_sof_amd_acp,snd_hda_codec_hdmi,snd_pci_acp6x,snd_hda_intel,snd_hda_ codec,snd_sof,snd_acp6x_pdm_dma,snd_compress,snd_soc_core,snd_sof_utils ,snd_hda_core,snd_pci_ps,snd_pcm_dmaengine

ecc 45056 1 ecdh_generic

usbhid 77824 0

mc 86016 4 videodev,videobuf2_v4l2,uvcvideo,videobuf2_common

snd_soc_acpi 20480 2 snd_sof_amd_acp,snd_acp_config

i2c_algo_bit 16384 1 amdgpu

snd_pci_acp3x 16384 0

snd_timer 49152 3 snd_seq,snd_hrtimer,snd_pcm

intel_rapl_msr 20480 0

intel_rapl_common 40960 1 intel_rapl_msr

edac_mce_amd 28672 0

kvm_amd 208896 0

ccp 143360 1 kvm_amd

qrtr 53248 7 qrtr_mhi

ath11k_pci 32768 0

kvm 1437696 1 kvm_amd

ath11k 868352 1 ath11k_pci

irqbypass 12288 1 kvm

crct10dif_pclmul 12288 1

qmi_helpers 32768 1 ath11k

polyval_clmulni 12288 0

polyval_generic 12288 1 polyval_clmulni

ses 20480 0

ghash_clmulni_intel 16384 0

enclosure 24576 1 ses

mac80211 1728512 1 ath11k

sha256_ssse3 32768 0

scsi_transport_sas 57344 1 ses

sha1_ssse3 32768 0

aesni_intel 356352 8

crypto_simd 16384 1 aesni_intel

cryptd 28672 3 crypto_simd,ghash_clmulni_intel

cfg80211 1339392 2 ath11k,mac80211

uas 28672 1

usb_storage 90112 1 uas

rapl 20480 0

libarc4 12288 1 mac80211

think_lmi 45056 0

firmware_attributes_class 12288 1 think_lmi

thinkpad_acpi 163840 0

wmi_bmof 12288 0

mhi 106496 2 ath11k_pci,qrtr_mhi

k10temp 16384 0

i2c_piix4 32768 0

nvram 16384 1 thinkpad_acpi

amd_pmc 45056 0

input_leds 12288 0

joydev 32768 0

serio_raw 20480 0

mac_hid 12288 0

msr 12288 0

parport_pc 53248 0

ppdev 24576 0

lp 28672 0

parport 77824 3 parport_pc,lp,ppdev

efi_pstore 12288 0

nfnetlink 20480 1

dmi_sysfs 24576 0

ip_tables 36864 0

x_tables 69632 1 ip_tables

autofs4 57344 2

nvme 61440 2

hid_multitouch 36864 0

ucsi_acpi 12288 0

snd 147456 22 snd_ctl_led,snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_ hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek,snd_so f,snd_timer,snd_compress,thinkpad_acpi,snd_soc_core,snd_pcm,snd_rawmidi

nvme_core 212992 3 nvme

hid_generic 12288 0

typec_ucsi 61440 1 ucsi_acpi

soundcore 16384 2 snd_ctl_led,snd

xhci_pci 24576 0

video 73728 2 thinkpad_acpi,amdgpu

crc32_pclmul 12288 0

ledtrig_audio 12288 2 snd_ctl_led,thinkpad_acpi

psmouse 217088 0

thunderbolt 512000 0

xhci_pci_renesas 20480 1 xhci_pci

i2c_hid_acpi 12288 0

nvme_auth 28672 1 nvme_core

typec 110592 1 typec_ucsi

platform_profile 12288 1 thinkpad_acpi

i2c_hid 40960 1 i2c_hid_acpi

wmi 32768 3 video,wmi_bmof,think_lmi

hid 184320 4 i2c_hid,usbhid,hid_multitouch,hid_generic

)

dcpetit
  • 47

3 Answers3

6

All out-of-tree kernel module stuff e.g. tp-smapi, acpi_call, tpacpi-bat is obsolete for your model and kernel.

Just install the package tlp and configure charge thresholds by uncommenting and editing the corresponding lines in /etc/tlp.conf:

START_CHARGE_THRESH_BAT0=60
STOP_CHARGE_THRESH_BAT0=85

Then activate the new thresholds via the command line

sudo tlp setcharge

and check the result with

sudo tlp-stat -b

Instead of any googled reading from the Linux stone age, I recommend the up-to-date official documentation for TLP:

linrunner
  • 1,525
1

My settings (tlp is not needed)

echo 27 | sudo tee /sys/class/power_supply/BAT0/charge_start_threshold
echo 87 | sudo tee /sys/class/power_supply/BAT0/charge_stop_threshold

see https://linuxconfig.org/how-to-set-battery-charge-thresholds-on-linux for more discussions.

0

Here is a bash script that will notify you whenever the charge is above 80%:

#!/bin/bash
battery_percentage=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E 'percentage' | grep -o -E '[0-9]+')

echo $battery_percentage

if [ $battery_percentage -gt 60 ]; then notify-send "Battery Above 80%" fi

You can add it to systemd as a daemon and it'll notify you whenever the battery is above 80%.

The only requirement is libnotify that can be installed with this command:

sudo apt install libnotify4
Amirreza
  • 435