execbar can now be used in the shell even when compiled with x11 support
authorNikolas Garofil <garo@dunaldi.garofil.be>
Sun, 17 May 2009 11:38:51 +0000 (13:38 +0200)
committerNikolas Garofil <garo@dunaldi.garofil.be>
Sun, 17 May 2009 11:38:51 +0000 (13:38 +0200)
src/conky.c
src/conky.h
src/specials.c

index ac75824..0125523 100644 (file)
@@ -3799,26 +3799,29 @@ static void generate_text_internal(char *p, int p_max_size,
 #endif
                        OBJ(execbar) {
                                double barnum;
-#ifndef X11
                                int i;
-#endif
 
                                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)='_';
+                                       if(output_methods & TO_X) {
+                                               barnum /= 100;
+                                               new_bar(p, obj->a, obj->b, round_to_int(barnum * 255.0));
+                                       }else{
+#endif
+                                               if(!obj->a) obj->a = DEFAULT_BAR_WIDTH_NO_X;
+                                               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;
+#ifdef X11
                                        }
-                                       *(p+i)=0;
 #endif
                                }
                        }
index b12952e..bbbdc14 100644 (file)
@@ -43,6 +43,7 @@
 #define FALSE 0
 #define TRUE 1
 
+#define DEFAULT_BAR_WIDTH_NO_X 10
 
 #if !defined(__GNUC__)
 #  define __attribute__(x) /* nothing */
index 3d57f3c..0c6f84c 100644 (file)
@@ -42,12 +42,10 @@ struct special_t *specials = NULL;
 
 unsigned int special_count;
 
-#ifdef X11
 int default_bar_width = 0, default_bar_height = 6;
+#ifdef X11
 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
 
 /*