int main(void) { struct items { char *up; char *load; char *fan; char *temp; char *mem; char *swap; char *diskio; char *fs_root; char *fs_home; char *fs_storage; char *net_speed; char *batt; char *vol; char *time; char *status; }; if (!(dpy = XOpenDisplay(NULL))) { fprintf(stderr, "dwmstatus: cannot open display.\n"); return 1; } struct items *i = malloc(sizeof(struct items)); while(1) { i->up = get_up(); i->load = get_load(); i->fan = get_fan(); i->temp = get_temp(); i->mem = get_mem(); i->swap = get_swap(); i->diskio = get_diskio("sda"); i->fs_root = get_space("/"); i->fs_home = get_space("/home"); i->net_speed = get_net_speed(); i->batt = get_batt(); i->vol = get_vol(); i->time = mktimes("%m/%d/%Y %a %H:%M", tzkiev); i->status = smprintf( "up:%s la:%s fan:%s temp:%s m:%s s:%s io:%s /:%s " "~/:%s net:%s bat:%s vol:%s %s", i->up, i->load, i->fan, i->temp, i->mem, i->swap, i->diskio, i->fs_root, i->fs_home, i->net_speed, i->batt, i->vol, i->time); setstatus(i->status); sleep(INTERVAL); } free(i); XCloseDisplay(dpy); return EXIT_SUCCESS; }
int main(int argc, char **argv) { ad_connect_am(); get_powerzone_collection(0); get_powerzone(0); get_psu_collection(0); get_psu(0, 0); get_thermalzone_collection(); get_tz(0); get_fan_collection(0); get_fan(0, 0); get_drawer_collection(); get_drawer(0); return 0; }
int main (int argc, char **argv) { int res, c, verbose=FALSE; int fan, temp, newpwm, oldpwm=0; pid_t pid; uid_t uid; printf("eeepc-fanctld v%s - (c)2012 Pau Oliva Fora <*****@*****.**>\n",VERSION); while ((c = getopt(argc, argv, "vh?")) != EOF) { switch(c) { case 'v': verbose=TRUE; break; case 'h': printf("usage: eeepc-fanctld [-v]\n"); return 0; break; default: fprintf(stderr,"usage: eeepc-fanctld [-v]\n"); return 1; break; } } uid = getuid(); if (uid != 0) { fprintf(stderr, "Error: this daemon must be run as root user.\n"); return 1; } find_eeepc(); sensors_init(NULL); if (!init_sensor_data()) { fprintf(stderr, "Error: Could not find needed sensors\n"); return 1; } if (!pwm_enable(1)) { fprintf(stderr, "Error: could not enable pwm\n"); return 1; } if (!verbose) { if ((pid = fork()) < 0) exit(1); else if (pid != 0) exit(0); /* daemon running here */ setsid(); res=chdir("/"); if (res != 0) { perror("Error: Could not chdir"); exit(1); } umask(0); } signal_installer(); while(1) { temp=get_temp(); if (verbose) { fan=get_fan(); printf("FAN: %d RPM, TEMP: %dºC\n", fan, temp); } if (temp < 55) newpwm=0; else if(temp < 60) newpwm=(10*255)/100; else if(temp < 65) newpwm=(20*255)/100; else if(temp < 67) newpwm=(30*255)/100; else if(temp < 69) newpwm=(40*255)/100; else if(temp < 74) newpwm=(50*255)/100; else if(temp < 77) newpwm=(60*255)/100; else if(temp < 81) newpwm=(65*255)/100; else if(temp < 85) newpwm=(70*255)/100; else if(temp < 91) newpwm=(80*255)/100; else newpwm=255; if (newpwm != oldpwm) { if(verbose) printf("Changing fan speed from: %d to %d\n", oldpwm, newpwm); set_fan(newpwm); oldpwm=newpwm; } usleep(POLLTIME*1000000); } return 0; }