1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-27 04:32:55 +00:00

Execbar can now also be used on the shell

This commit is contained in:
Nikolas Garofil 2009-05-17 00:37:22 +02:00
parent 3762c5cb10
commit dae78fb875
4 changed files with 25 additions and 7 deletions

View File

@ -719,9 +719,9 @@ static void free_text_objects(struct text_object *root)
case OBJ_image:
case OBJ_eval:
case OBJ_exec:
case OBJ_execbar:
#ifdef X11
case OBJ_execgauge:
case OBJ_execbar:
case OBJ_execgraph:
#endif
case OBJ_execp:
@ -1472,13 +1472,13 @@ static struct text_object *construct_text_object(const char *s,
obj->a = default_##arg##_width; \
obj->b = default_##arg##_height; \
}
END OBJ(execbar, 0)
SIZE_DEFAULTS(bar);
obj->data.s = strndup(arg ? arg : "", text_buffer_size);
#ifdef X11
END OBJ(execgauge, 0)
SIZE_DEFAULTS(gauge);
obj->data.s = strndup(arg ? arg : "", text_buffer_size);
END OBJ(execbar, 0)
SIZE_DEFAULTS(bar);
obj->data.s = strndup(arg ? arg : "", text_buffer_size);
END OBJ(execgraph, 0)
SIZE_DEFAULTS(graph);
obj->data.s = strndup(arg ? arg : "", text_buffer_size);
@ -3789,17 +3789,31 @@ static void generate_text_internal(char *p, int p_max_size,
new_gauge(p, obj->a, obj->b, round_to_int(barnum * 255.0));
}
}
#endif
OBJ(execbar) {
double barnum;
int i;
read_exec(obj->data.s, p, text_buffer_size);
barnum = get_barnum(p);
if (barnum >= 0.0) {
#ifdef X11
barnum /= 100;
new_bar(p, obj->a, obj->b, round_to_int(barnum * 255.0));
#else
barnum = round_to_int( ( barnum * obj->a ) / 100);
for(i=0; i<barnum; i++) {
*(p+i)='#';
}
for(; i < obj->a; i++) {
*(p+i)='_';
}
*(p+i)=0;
#endif
}
}
#ifdef X11
OBJ(execgraph) {
char showaslog = FALSE;
double barnum;
@ -7108,7 +7122,6 @@ static void load_config_file(const char *f)
CONF_ERR;
}
}
#ifdef X11
CONF("default_bar_size") {
char err = 0;
if (value) {
@ -7122,6 +7135,7 @@ static void load_config_file(const char *f)
CONF_ERR2("default_bar_size takes 2 integer arguments (ie. 'default_bar_size 0 6')")
}
}
#ifdef X11
CONF("default_graph_size") {
char err = 0;
if (value) {

View File

@ -46,11 +46,15 @@ unsigned int special_count;
int default_bar_width = 0, default_bar_height = 6;
int default_graph_width = 0, default_graph_height = 25;
int default_gauge_width = 50, default_gauge_height = 25;
#else
int default_bar_width = 10, default_bar_height = 1;
#endif
/*
* Scanning arguments to various special text objects
*/
#ifdef X11
const char *scan_gauge(const char *args, int *w, int *h)
{
/*width and height*/

View File

@ -76,9 +76,9 @@ struct special_t {
extern struct special_t *specials;
extern unsigned int special_count;
#ifdef X11
extern int default_bar_width;
extern int default_bar_height;
#ifdef X11
extern int default_graph_width;
extern int default_graph_height;
extern int default_gauge_width;

View File

@ -104,9 +104,9 @@ enum text_object_type {
OBJ_exec,
OBJ_execi,
OBJ_texeci,
OBJ_execbar,
#ifdef X11
OBJ_execgauge,
OBJ_execbar,
OBJ_execgraph,
OBJ_execibar,
OBJ_execigraph,