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.
Best Answer
Create a new rule in udev by opening the terminal and using:
(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 assudo -H gedit /etc/udev/rules.d/50-ac-unplugged.rules
)Put in the following line:
Save the file and then restart udev services with:
Save all your work and unplug your power supply.