Views:
3,031
Votes: 7
✅ Solution
Tags:
power-management
shutdown
battery
automation
Link:
🔍 See Original Answer on Ask Ubuntu ⧉ 🔗
URL:
https://askubuntu.com/q/854756
Title:
How to shutdown automatically when AC power is not available
ID:
/2016/11/29/How-to-shutdown-automatically-when-AC-power-is-not-available
Created:
November 29, 2016
Edited: April 9, 2019
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
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.