[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ACPI et batterie faible



Coletta Rémi a écrit:

Bonjour,

  Sur mon portable kernel 2.4.19 + patch-acpi-acpi20020918-swsusp15,
je n'arrive pas à obtenir un message d'alerte en cas de batterie faible:

 - Rien dans les logs de acpid (aucun evenement )
- $ cat /proc/acpi/battery/BAT1/alarm alarm: unsupported
 J'ai essayé avec le pluggin gkacpi, mais sans succès :(

Ça serait bien de le faire marcher.


J'aurais espéré que acpi fasse ça pour moi, un script dans cron
qui lirait /proc/acpi/battery/BAT1/state me parait geek (très geek)

Une idée ?
c'est un palliatif, mais qui fonctionne

xg@valiho:~$ cat /etc/cron.d/anacron
# Run queue every 5 minutes
03,08,13,18,23,28,33,38,43,48,53,58 * * * * root /usr/bin/gawk -f /etc/acpi/qbatt -v mini=12 /proc/acpi/battery/BAT1/*

xg@valiho:~$ cat /etc/acpi/qbatt
#!/usr/bin/awk

BEGIN {
       etat="?"
       mode="?"
#printf ("ARGC=%d (0)=%s (1)=%s (2)=%s\n",ARGC,ARGV[0],ARGV[1],ARGV[2])
       cons=99999
       rest=0
       volt=0
       tota=99999
       printf(strftime("%d/%m/%Y %H:%M:%S ",systime()))  >> "/var/log/batt"
}

{

#       capacity state:          ok
#       charging state:          discharging
#       present rate:            23943 mW
#       remaining capacity:      51700 mWh
#       present voltage:         15752 mVi

       if (/design capacity:/)         tota=$3
       if (/capacity state:/)          etat=$3
       if (/charging state:/)          mode=substr($3,1,5)
       if (/present rate:/)            cons=$3
       if (/remaining capacity:/)      rest=$3
       if (/present voltage:/)         volt=$3

}


END {
       getline < "/proc/acpi/thermal_zone/ATF0/temperature"
       temp=$2
       perc=(100*rest)/tota
       if (mode=="charg") {
               printf(etat " " mode " V=%d R=%d %d%% " temp "° C=%d\n",
                       volt,rest,perc,cons) >> "/var/log/batt"
       }
       else {
               dure=(rest*3600)/cons
               durm=(rest*60)/cons

printf(etat " " mode " V=%d R=%d %d%% " temp "° C=%d (%d s / %d mn)\n",
                       volt,rest,perc,cons,dure,durm) >> "/var/log/batt"

if (perc<mini) system("echo \"batt. faible " perc "%\" | wall")
       }
} xg@valiho:~$






Reply to: