void print_smapi_bat_bar(struct text_object *obj, char *p, int p_max_size) { if (!p_max_size) return; if (obj->data.i >= 0 && smapi_bat_installed(obj->data.i)) new_bar(obj, p, p_max_size, (int) (255 * smapi_get_bat_int(obj->data.i, "remaining_percent") / 100)); else new_bar(obj, p, p_max_size, 0); }
void print_lua_bar(struct text_object *obj, char *p, int p_max_size) { double per; if (llua_getnumber(obj->data.s, &per)) { new_bar(obj, p, p_max_size, (per/100.0 * 255)); } }
void print_entropy_bar(struct text_object *obj, char *p, int p_max_size) { double ratio; (void)obj; ratio = (double) entropy.avail / (double) entropy.poolsize; new_bar(obj, p, p_max_size, (int) (ratio * 255.0f)); }
void print_execbar(struct text_object *obj, char *p, int p_max_size) { double barnum; read_exec(obj->data.s, p, p_max_size, 1); barnum = get_barnum(p); if (barnum >= 0.0) { barnum /= 100; new_bar(obj, p, p_max_size, round_to_int(barnum * 255.0)); } }
/* see print_mixer() above for a description of 'chan' */ static void print_mixer_bar_chan(struct text_object *obj, int chan, char *p, int p_max_size) { int val; if (!p_max_size) return; if (chan < 0) val = mixer_get_left(obj->data.i); else if (chan == 0) val = mixer_get_avg(obj->data.i); else val = mixer_get_right(obj->data.i); new_bar(obj, p, p_max_size, mixer_to_255(obj->data.i, val)); }
// Create list of Bar objects Bar* create_bar_list(void) { Bar *pFirst = NULL; // Address of the first object Bar *pBar = NULL; // Stores address of new object Bar *pCurrent = NULL; // Address of current object while(pBar = new_bar()) { if(pCurrent) { // There is a current object, so this is not the first pCurrent->pNext = pBar; // New address in pNext for current pCurrent = pBar; // Make new one current } else // This is the first... pFirst = pCurrent = pBar; // ...so just save it. } return pFirst; }
void print_execibar(struct text_object *obj, char *p, int p_max_size) { struct execi_data *ed = obj->data.opaque; double barnum; if (!ed) return; if (time_to_update(ed)) { read_exec(ed->cmd, p, p_max_size, 1); barnum = get_barnum(p); if (barnum >= 0.0) { ed->barnum = barnum; } ed->last_update = current_update_time; } new_bar(obj, p, p_max_size, round_to_int(ed->barnum * 2.55)); }
void print_mpd_bar(struct text_object *obj, char *p, int p_max_size) { new_bar(obj, p, p_max_size, (int) (mpd_get_info()->progress * 255.0f)); }