static void timer_cb(void *data) { char buff[64]; double d1, d2, d3; get_load_average(&d1, &d2, &d3); one = ((d1 > 100.0) ? (100) : ((int)d1)); five = ((d2 > 100.0) ? (100) : ((int)d2)); fifteen = ((d3 > 100.0) ? (100) : ((int)d3)); Epplet_gadget_data_changed(vbar1); Epplet_gadget_data_changed(vbar2); Epplet_gadget_data_changed(vbar3); Esnprintf(buff, sizeof(buff), "%3.2f", d1); Epplet_change_label(label1, buff); Esnprintf(buff, sizeof(buff), "%3.2f", d2); Epplet_change_label(label2, buff); Esnprintf(buff, sizeof(buff), "%3.2f", d3); Epplet_change_label(label3, buff); Epplet_timer(timer_cb, NULL, 5.0, "TIMER"); return; data = NULL; }
/* callback_function to update the volumes with a timer */ static void update_volumes_callback(void *data) { channels[0].value = read_volume(0); channels[1].value = read_volume(1); channels[2].value = read_volume(2); channels[3].value = read_volume(3); Epplet_gadget_data_changed(vs_master); Epplet_gadget_data_changed(vs_pcm); Epplet_gadget_data_changed(vs_lin); Epplet_gadget_data_changed(vs_cda); Epplet_timer(update_volumes_callback, NULL, 0.5, "TIMER"); }
void set_volume(void *data) { unsigned char lrvl[4]; MIX_CHANNEL *dev = (MIX_CHANNEL *) data; if (mute_status) { mute_status = 0; toggle_mute(&channels[0]); Epplet_gadget_data_changed(b_mute); } lrvl[0] = (20 - (unsigned char)dev->value) * 5; lrvl[1] = lrvl[0]; lrvl[2] = lrvl[3] = 0; ioctl(fd_mixer, MIXER_WRITE(dev->id), lrvl); }
void temporizador(void *datos){ FILE *aTemp; FILE *aFreq; aTemp=fopen("/sys/class/hwmon/hwmon0/temp1_input","r"); fgets(textoTemperatura,3,aTemp); fclose(aTemp); aFreq=popen("cpufreq-info -f","r"); fgets(texto,5,aFreq); if(texto[0]=='8')texto[3]='\0'; pclose(aFreq); temperatura=atoi(textoTemperatura); Epplet_gadget_data_changed(barra); sprintf(textoTemperatura,"%s C",textoTemperatura); Epplet_change_label(visorNumerico,texto); Epplet_change_label(visorTemperatura,textoTemperatura); Esync(); Epplet_timer(temporizador, NULL, REFRESCO, "TIMER"); //datos = NULL; }
static void timer_cb(void *data) { char buff[1024]; double val = -1.0, val2 = -1.0; unsigned char invalid; unsigned long in_bytes, out_bytes; static unsigned long in_delta = -1, out_delta = -1; invalid = net_get_bytes_inout(device_string, &val, &val2); if (invalid) { D(("Failed to open %s -- %s\n", device_string, strerror(errno))); Esync(); Epplet_timer(timer_cb, NULL, 10.0, "TIMER"); return; } if ((last_in == 0) && (last_out == 0)) { last_in = (unsigned long)val; last_out = (unsigned long)val2; Esync(); Epplet_timer(timer_cb, NULL, 1.0, "TIMER"); return; } in_bytes = (unsigned long)val - last_in; out_bytes = (unsigned long)val2 - last_out; D(("In %lu, out %lu\n", in_bytes, out_bytes)); if (in_bytes > max_in) { max_in = in_bytes; Esnprintf(buff, sizeof(buff), "%lu", max_in); Epplet_modify_config("max_in", buff); D(("Set max_in to %lu\n", max_in)); } if (in_bytes != in_delta) { in_val = (int)((((float)in_bytes) / max_in) * 100.0); Epplet_gadget_data_changed(in_bar); sprintf(buff, "I: "); show_size(in_bytes, buff + 3); strcat(buff, "/s"); Epplet_change_label(in_label, buff); in_delta = in_bytes; } last_in += in_bytes; if (out_bytes > max_out) { max_out = out_bytes; Esnprintf(buff, sizeof(buff), "%lu", max_out); Epplet_modify_config("max_out", buff); D(("Set max_out to %lu\n", max_out)); } if (out_bytes != out_delta) { out_val = (int)((((float)out_bytes) / max_out) * 100.0); Epplet_gadget_data_changed(out_bar); sprintf(buff, "O: "); show_size(out_bytes, buff + 3); strcat(buff, "/s"); Epplet_change_label(out_label, buff); out_delta = out_bytes; } last_out += out_bytes; Esync(); Epplet_timer(timer_cb, NULL, 1.0, "TIMER"); return; data = NULL; }
static void timer_cb(void *data) { FILE *fp; char buff[1024]; unsigned long a, b, c, d, e; unsigned long in_blks = 0, out_blks = 0; static unsigned long last_in = 0, last_out = 0, in_delta = 0, out_delta = 0; if (!(fp = fopen("/proc/diskstats", "r"))) { if (!(fp = fopen("/proc/stat", "r"))) { D(("Failed to open /proc/stat -- %s\n", strerror(errno))); return; } } for (; fgets(buff, sizeof(buff), fp);) { if (BEGMATCH(buff, "disk_rblk")) { sscanf(buff, "%*s %lu %lu %lu %lu", &a, &b, &c, &d); in_blks = a + b + c + d; fgets(buff, sizeof(buff), fp); sscanf(buff, "%*s %lu %lu %lu %lu", &a, &b, &c, &d); out_blks = a + b + c + d; } else if (BEGMATCH(buff, "disk_io")) { char *pbuff = buff + 9; for (in_blks = out_blks = 0; *pbuff == '('; pbuff = strchr(pbuff, ' ') + 1) { pbuff = strchr(++pbuff, '('); sscanf(++pbuff, "%lu,%lu,%lu,%lu,%lu", &a, &b, &c, &d, &e); in_blks += c; out_blks += e; } } else { char tmp[64]; /* Hopefully no one can exploit /proc/diskstats without root. :-) */ sscanf(buff, "%lu %lu %s %*u %*u %lu %*u %*u %*u %lu", &a, &b, tmp, &c, &d); /* Check for hdX or sdX, or md#, or...??? */ if ((((*tmp == 'h') || (*tmp == 's')) && (tmp[1] == 'd') && (isalpha(tmp[2])) && (tmp[3] == 0)) || ((*tmp == 'm') && (tmp[1] == 'd') && (isdigit(tmp[2])))) { in_blks += c; out_blks += d; } } } in_blks -= last_in; out_blks -= last_out; fclose(fp); if (last_in) { /* We must have some history data to do anything. */ if (in_blks > max_in) { max_in = in_blks; Esnprintf(buff, sizeof(buff), "%lu", max_in); Epplet_modify_config("max_in", buff); } if (in_blks != in_delta) { in_val = (int)((((float)in_blks) / max_in) * 100.0); Epplet_gadget_data_changed(in_bar); sprintf(buff, "I: "); show_size(in_blks * 512, buff + 3); strcat(buff, "/s"); Epplet_change_label(in_label, buff); } in_delta = in_blks; } last_in += in_blks; if (last_out) { /* We must have some history data to do anything. */ if (out_blks > max_out) { max_out = out_blks; Esnprintf(buff, sizeof(buff), "%lu", max_out); Epplet_modify_config("max_out", buff); } if (out_blks != out_delta) { out_val = (int)((((float)out_blks) / max_out) * 100.0); Epplet_gadget_data_changed(out_bar); sprintf(buff, "O: "); show_size(out_blks * 512, buff + 3); strcat(buff, "/s"); Epplet_change_label(out_label, buff); } out_delta = out_blks; } last_out += out_blks; Esync(); Epplet_timer(timer_cb, NULL, 1.0, "TIMER"); return; data = NULL; }