close

when i update kernel 2.6.38 from 2.6.35 today morning .
I found /proc/acpi/temperature move to /sys/

but my Lxde temperature monitor show NA .
I get the lxpanel code from git.

35 //#define THERMAL_DIRECTORY "/proc/acpi/thermal_zone/" /* must be slash-terminated */

36 #define THERMAL_DIRECTORY "/sys/class/thermal/thermal_zone0/" /* must be slash-terminated */

static gint
get_temperature(thermal *th){
        FILE *state;
        char buf[ 256 ], sstmp [ 100 ];
        char* pstr;
        //if(th->sensor == NULL) return -1;
        //sprintf(sstmp,"%s%s",th->sensor,THERMAL_TEMPF);
        //if (!(state = fopen( sstmp, "r"))) {
        if (!(state = fopen( "/sys/class/thermal/thermal_zone0/temp", "r"))) {
                //printf("cannot open %s\n",sstmp);
                return 20; 
                //return -1;
        }   
        //while( fgets(buf, 256, state) &&
        //        ! ( pstr = strstr(buf, "temperature:") ) );
        while( fgets(buf, 256, state) );
        pstr=buf;
        if( pstr )
        {   
                /*  
                   pstr += 12;
                   while( *pstr && *pstr == ' ' )
                   ++pstr;
                   */
                //pstr[strlen(pstr)-3] = '\0';
                pstr[2] = '\0';
                fclose(state);
                return atoi(pstr);

                //return atoi("15");
        }   

        fclose(state);
        return -1; 
}

 


花了一個早上再搞自規版的lxde temperature monitor
看看本來的code跟自己土炮的...
只有會心一笑而已XD

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 peicheng 的頭像
    peicheng

    FLASHC

    peicheng 發表在 痞客邦 留言(0) 人氣()