You can test whether the rule worked by unplugging your laptop and looking for this file. This creates a file at /home/example/discharging when the laptop charger is unplugged. If your system has no or missing ACPI events, frequently run the following script which uses acpi:Īcpi -b | awk -F'' '="Discharging", RUN+="/usr/bin/touch /home/example/discharging" Other rules can be added to perform different actions depending on power supply status and/or capacity. The -i flag can be used to ignore shutdown inhibitors, see systemctl(1) § OPTIONS. To shutdown the system instead of hibernating, use /usr/bin/systemctl poweroff. Such new attribute/value pair can be obtained for example by checking /sys/class/power_supply/ nameOfMainBattery/ attributesAndOtherDirectories, or by running udevadm monitor -property and waiting for battery events.īatteries can jump to a lower value instead of discharging continuously, therefore a udev string matching pattern for all capacities 0 through 5 is used. If you have more than one battery or if you are using a battery powered peripheral device, the rule could be triggered unexpectedly by another battery discharging this can be fixed by obtaining another attribute/value pair to add to your udev rule that specifically match the main battery, for example model_name. Some laptops do not boot beyond a certain battery level, so the rule could be adjusted accordingly. As such, when resuming from hibernate when the battery is critical, the computer will hibernate directly. This rule will be repeated whenever the condition is set. For instance, /usr/bin/systemctl hibernate may return the error: "Call to Hibernate failed: Not enough swap space for hibernation"
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |