Wednesday, May 22, 2024
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 2372  / 2 Years ago, sun, june 12, 2022, 6:27:09

My old laptop has a faulty battery, which shows 100% when on AC power but when unplugged it dramatically drops to random percentages within seconds and makes the machine turn off brutally. I am afraid of damaging my SSD (and my HDD) on which Ubuntu is loaded.



I wanted to turn the PC off as soon as the AC power is not available. I searched here and found this. But I don't understand the answer for that question or atleast it is relevant to my situation.



Please explain me a way to shut down my laptop automatically as soon as the AC power is unplugged or when there is a power failure.


More From » power-management

 Answers
0

Create a new rule in udev by opening the terminal and using:



gksu gedit /etc/udev/rules.d/50-ac-unplugged.rules


(If you are using Ubuntu 18.04 or a newer version gksu will not be available by default. In that situation please refer this question or use the above command as sudo -H gedit /etc/udev/rules.d/50-ac-unplugged.rules)



Put in the following line:



SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/sbin/shutdown now"


Save the file and then restart udev services with:



sudo udevadm control --reload-rules


Save all your work and unplug your power supply.


[#12912] Monday, June 13, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
pipeag

Total Points: 489
Total Questions: 107
Total Answers: 115

Location: Iraq
Member since Fri, Jun 5, 2020
4 Years ago
;