You are not logged in.
Do a find for a "BAT" in /sys:
:find /sys|grep BAT
On my system there is BAT1 entry and battery sends udev event on discharging by 1 percent.
Last edited by eruditorum (2013-02-13 12:40:54)
Offline
Ok, so I have BAT0
looking at device '/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:00/PNP0C09:00/PNP0C0A:00/power_supply/BAT0':
KERNEL=="BAT0"
SUBSYSTEM=="power_supply"
DRIVER==""
ATTR{type}=="Battery"
ATTR{power_now}=="0"
ATTR{alarm}=="2045000"
ATTR{capacity}=="97"
ATTR{status}=="Unknown"
ATTR{voltage_now}=="12471000"
ATTR{energy_now}=="40080000"
ATTR{model_name}=="42T5233"
ATTR{manufacturer}=="Panasonic"
ATTR{technology}=="Li-ion"
ATTR{cycle_count}=="0"
ATTR{energy_full_design}=="51830000"
ATTR{voltage_min_design}=="10800000"
ATTR{serial_number}==" 1954"
ATTR{energy_full}=="40900000"
ATTR{present}=="1"
and I wrote the rule
/etc/udev/rules.d/85-autohibernate.rules
## SLEEP/HIBERNATE IF BATTERY IS LOW
SUBSYSTEM=="power_supply", ATTR{type}=="Battery", ATTR{status}=="Discharging", ATTR{capacity}=="95", RUN+="/usr/bin/systemctl suspend"
but it does not sleep on or below 95%.
Offline
Did you forget to do udevadm control --reload as root after writing the rule?
If that really doesn't work, try to remove ATTR{status} from the rule (as I see "Unknown" in your udev info), and instead of systemd provide your own script.
In the script you determine whether ac is on or not and then hibernate.
Last edited by eruditorum (2013-02-13 12:50:01)
Offline
Did you forget to do udevadm control --reload as root after writing the rule?
Yes, I did. But as I run it now with battery at 55%, the system still not hibernates, which bares the question whether it is because the rule runs only on = instaed of <=.
Offline
only on "==" or "!=".
You can use "!=" or completely remove ATTR{capacity}=="95", and check the charge in script instead!
Last edited by eruditorum (2013-02-13 14:10:25)
Offline
I changed it to != and computer did not sleep on 95%. Instead, it went to sleep at 80%...
What's going on?
Offline