scripts

shell scripts
git clone git://git.bitsmanent.org/scripts
Log | Files | Refs | README

commit 298bf2ce85c91ddbece60aa1e9731a42d90604d5
parent 3e8cf84b8145cedd086e1a6af75c2445b877a717
Author: clamiax <smoppy@gmail.com>
Date:   Tue, 12 Nov 2013 22:23:56 +0100

Add support for LID and improve the code a bit.

Diffstat:
Macpi | 12+++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/acpi b/acpi @@ -5,11 +5,8 @@ STATE=mem BATTCRITIC=3 BATTWARNING=8 -ACDEVFILE=/sys/devices/pci0000:00/firmware_node/ACPI0003:00/power_supply/AC0/online - -acplugged() { - cat "$ACDEVFILE" -} +ACPLUGGED="$(cat /sys/devices/pci0000:00/firmware_node/ACPI0003:00/power_supply/AC0/online)" +LIDSTATE="$(cat /proc/acpi/button/lid/LID/state |awk '{print $2}')" warning() { xmessage -center "WARNING: battery level is ${t}%" @@ -29,9 +26,10 @@ getbattery() { } main() { - [ $(acplugged) -eq 1 ] && exit - t=$(getbattery) + [ $LIDSTATE = "closed" ] && suspend + [ $ACPLUGGED -eq 1 ] && exit + t=$(getbattery) [ $t -le $BATTCRITIC ] && suspend [ $t -le $BATTWARNING ] && warning $t }