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)" != ...
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 ...
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 ...
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 ...
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=...
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-...
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 ...
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 (...
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-...
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 ...
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/...
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% ...
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 ...
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 ...
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)...
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 ...
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.
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 ...
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:
...
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 ...
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
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....
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 ...
3
votes
Accepted
Void Linux upower issues
The solution is to add dbus to the services: ln -s /etc/sv/dbus /var/service/
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 ...
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 ...
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 ...
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 ...
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 ~ ~ ~ ~ ~ ~ ~
~ ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
battery × 192power-management × 67
linux × 39
laptop × 31
acpi × 20
debian × 19
ubuntu × 14
thinkpad × 13
linux-mint × 12
arch-linux × 11
hardware × 8
suspend × 8
kernel × 7
cpu × 7
linux-kernel × 5
shutdown × 5
shell-script × 4
kde × 4
i3 × 4
asus × 4
bash × 3
fedora × 3
scripting × 3
boot × 3
gnome × 3