Skip to main content
15 votes

How do I make my laptop sleep when it reaches some low battery threshold?

As of Debian ≥ 10 (and comparably recent Linux systems), you can just create a file /etc/cron.d/check-battery that contains: * * * * * root [ "$(cat /sys/class/power_supply/BAT0/status)" != ...
vog's user avatar
  • 428
10 votes
Accepted

How can I make this script run in the background?

You have 2 ways to do this: Add an ampersand after the command: ./battery-script.sh & This will keep the command running even after you close the terminal, by spawning a subprocess within your ...
juliethefoxcoon's user avatar
9 votes

How can I get an alert when my battery is about to die in Linux Mint?

With the help of all the information from all the answers here I created a script and put it in a repository on GitLab. It'll show notifications when: Your cable is unplugged and the battery goes ...
gitaarik's user avatar
  • 599
8 votes
Accepted

Why doesn't inotifywait report modifications made to battery capacity file?

As @rudib said in the comments, everything in /sys is virtual: the content of each file is created fresh from the corresponding kernel data structure whenever it's actually being read. So, there are ...
telcoM's user avatar
  • 114k
8 votes

How can I make this script run in the background?

Create a systemd timer unit to have it run at regular intervals in the background. /etc/systemd/system/my-batterywatcher.service [Unit] Description=my battery watcher [Service] Type=oneshot ExecStart=...
Gerald Schneider's user avatar
6 votes
Accepted

Understanding power_supply files

You might want to see how the Linux power-supply device class is defined in include/linux/power_supply.h in Linux kernel source code. The values in the data structures described there are presented as-...
telcoM's user avatar
  • 114k
6 votes
Accepted

Command to know if electricity went down? or to trigger an action when power electricity went out?

If your laptop loses power as soon as the electricity goes, there isn’t anything you can run on the laptop to handle that. However, if you get at least a few seconds, you can detect the loss of power ...
Stephen Kitt's user avatar
5 votes

Keep script running while computer is in suspension mode

No, when the system goes into hibernation or suspend mode, all user-level activity is suspended and will not resume until the system has left that mode. It is not possible to keep a script running (...
Kusalananda's user avatar
  • 356k
5 votes

How to check if my battery is healthy?

You can also check the battery health by using the inxi tool with this command : $ ./inxi -Bxxx Battery: ID-1: BAT0 charge: 39.5 Wh condition: 40.3/47.5 Wh (85%) volts: 10.8/10.8 model: PA5109U-...
SebMa's user avatar
  • 2,473
5 votes

How do I see how long the battery has been running without AC?

I think that upower -d can give you some answers, it shows info about the batteries. Another source of info is /sys/class/power_supply/XX where XX is any battery listed in the folder... You can see ...
Christopher Díaz Riveros's user avatar
4 votes

How to adjust charging thresholds of laptop battery?

Sounds to me like your TLP settings were changed somehow and now you would like to change them back. The TLP ArchWiki is pretty good even if you don't use Arch: https://wiki.archlinux.org/index.php/...
Allan Smithee's user avatar
4 votes

How to adjust charging thresholds of laptop battery?

On my laptop (Yoga 260) I had to get acpi-call-dkms, which provides the acpi_call kernel module: sudo apt install tlp acpi-call-dkms sudo tlp setcharge 40 60 #set the start and stop thresholds to 40% ...
takhisis's user avatar
4 votes

When using an external battery, do not charge on board battery just use running supply

For this model, you want acpi_call, then use the option to define charge thresholds. Basically the idea would be to set the maximum percentage to which the battery should be charged to the current ...
FelixJN's user avatar
  • 14.1k
4 votes

How can I make this script run in the background?

As already said, you can simply use & to run in background. If you need to detach/attach, the way to go is to use tmux or screen, that way, you can attach/detach a session as you need. To run a ...
Gilles Quénot's user avatar
4 votes

How can I make this script run in the background?

Several suggestions to run it in the background or as a conventional daemon, but this needs to run inside the session of the active user (since it wants to access the DISPLAY of the authenticated user)...
symcbean's user avatar
  • 6,339
3 votes

How to check if my battery is healthy?

full explain options and example on Ubuntu, you can open the Power Statistics application from the Dash. Look at the “Laptop battery” section. “Energy when full” is how much power your battery can ...
rdfleay's user avatar
  • 29
3 votes
Accepted

Manjaro on HP Laptop - Battery drain while powered off

Alright as it turned out that whatever the bug was, it seems to be fixed in kernel version 4.14.9-2. Upgrading to this kernel resolved the issue.
Raven's user avatar
  • 843
3 votes

Manjaro on HP Laptop - Battery drain while powered off

Presumably some part of your hardware fails to power down. Maybe a driver issue. You've shown us some stuff about bluetooth, and you're already looking at ethernet. Maybe this isrelevant, but ...
mc0e's user avatar
  • 1,096
3 votes
Accepted

Horrible performance on battery with intel_pstate driver

The issue was the intel_pstate driver. I switched to the original ACPI driver via boot kernel parameters. Specifically, in /etc/default/grub, I changed the DEFAULT boot line to: ...
rveale's user avatar
  • 161
3 votes

how to system-beep as low battery warning?

Yes, it is possible. One way is listening for udev events when the battery level changes, and comparing it against a threshold. Otherwise, this is a quick and dirty way. Make a systemd service to ...
Pheric's user avatar
  • 173
3 votes
Accepted

How to check battery history in a text format on debian?

See here: https://askubuntu.com/questions/113490/where-does-gnome-power-statistics-get-its-data-from#comment134330_113505 All data is logged to var/lib/upower/history-....dat
Big Bro's user avatar
  • 146
3 votes

Arch linux: restore session with running programs after running out of battery

First setup hibernation on arch, https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate#Hibernation Then create a udev rule to hibernate on low battery percentage, https://wiki....
pineappleFrenzy's user avatar
3 votes

TLP 1.4: Battery charge settings and performance question

OK, I appreciate I'm answering myself, but finally I was able to locate the right explanation on the software site. The explanation was a bit buried IMHO. Quoting from the site: ...having a battery ...
Andrea Moro's user avatar
3 votes
Accepted

Void Linux upower issues

The solution is to add dbus to the services: ln -s /etc/sv/dbus /var/service/
PerroNoob's user avatar
  • 141
3 votes
Accepted

Where does the ACPI battery information come from?

The actual knowledge of nominal battery capacity doesn't generally come from the same place. For example, I worked with small embedded devices that would only ever be shipped with the same battery ...
Marcus Müller's user avatar
2 votes

How to disable GPU without bbswitch

With the nouveau driver, "power management" can mean several things. On modern kernels, the nouveau driver knows how to access the same ACPI interface as bbswitch does, and will present it using ...
telcoM's user avatar
  • 114k
2 votes

How do I set battery charging threshold in linux on non Thinkpad laptop?

Most vendors to not expose such an API and there is not one in the Kernel, so either it's handled in hardware, or the BIOS (check for a setting there). The reason is lithium batteries can catch on ...
user1133275's user avatar
  • 5,711
2 votes

How do I fix the issue of delayed detection of charging in Plasma5?

(I am mostly doing this answer to provoke somebody else into making a better one to prevent me from earning the bounty undeservedly. Please make a better one. Please prefer upvoting any other answer ...
Yunnosch's user avatar
  • 171
2 votes
Accepted

What is difference in unit between energy-full vs charge_full?

According to the kernel documentation these values are in µAh (microampere-hour): ~ ~ ~ ~ ~ ~ ~ Charge/Energy/Capacity - how to not confuse ~ ~ ~ ~ ~ ~ ~ ~ ...
Artem S. Tashkinov's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible