Sensorsd behavior

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Sensorsd behavior

João Salvatti
Hi Misc,

I put the following line in my sensorsd.conf file:

hw.sensors.acpibat0.raw0:command=/etc/sensorsd/bat_status %2

When the battery's laptop status change, bat_status program is
executed using param %2 (sensor's value can be: 0 when battery is
idle, 1 when battery is discharging and 2 when battery is charging),
but the problem is: sensorsd only runs program bat_status when it is
started!

EG: If my power cord is plugged on my laptop sensorsd execute
bat_status, but when I remove my power cord the sensorsd doesn't run
bat_status again. Is this a normal behavior?

bat_status.c:

#include <stdio.h>
#include <syslog.h>
#include <stdarg.h>

int
main(int argc, char *argv[])
{
        int bat_status = atoi(argv[1]);

        if (bat_status == 0)
                syslog(LOG_WARNING, "Battery is now idle.\n");
        else if (bat_status == 1)
                syslog(LOG_WARNING, "Battery is now
discharging...\n");
        else
                syslog(LOG_WARNING, "Battery is now charging...\n");

        return 0;
}

Thanks in advance.

--
Joco Salvatti
Graduated in Computer Science
Federal University of Para - UFPA - Brazil
E-Mail: [hidden email]