infopipe_bar done
[monky] / src / conky.c
index 3d5d1ed..0f5560c 100644 (file)
@@ -86,7 +86,6 @@ struct font_list *fonts = NULL;
 
 static void set_font();
 
-
 int addfont(const char *data_in)
 {
        if (font_count > MAX_FONTS) {
@@ -227,6 +226,7 @@ static int gap_x, gap_y;
 
 /* border */
 static int draw_borders;
+static int draw_graph_borders;
 static int stippled_borders;
 
 static int draw_shades, draw_outline;
@@ -892,6 +892,31 @@ enum text_object_type {
        OBJ_mpd_track,
        OBJ_mpd_percent,
 #endif
+#ifdef BMPX
+       OBJ_bmpx_title,
+       OBJ_bmpx_artist,
+       OBJ_bmpx_album,
+       OBJ_bmpx_track,
+       OBJ_bmpx_uri,
+       OBJ_bmpx_bitrate,
+#endif
+#ifdef INFOPIPE
+       OBJ_infopipe_protocol,
+       OBJ_infopipe_version,
+       OBJ_infopipe_status,
+       OBJ_infopipe_playlist_tunes,
+       OBJ_infopipe_playlist_currtune,
+       OBJ_infopipe_usec_position,
+       OBJ_infopipe_position,
+       OBJ_infopipe_usec_time,
+       OBJ_infopipe_time,
+       OBJ_infopipe_bitrate,
+       OBJ_infopipe_frequency,
+       OBJ_infopipe_channels,
+       OBJ_infopipe_title,
+       OBJ_infopipe_file,
+       OBJ_infopipe_bar,
+#endif
 #ifdef TCP_PORT_MONITOR
        OBJ_tcp_portmon,
 #endif
@@ -974,6 +999,7 @@ struct text_object_list {
 
 static unsigned int text_object_count;
 static struct text_object *text_objects;
+static void generate_text_internal(char *p, int p_max_size, struct text_object *objs, unsigned int object_count, struct information *cur);
 
 pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
 
@@ -1003,20 +1029,6 @@ static struct text_object *new_text_object_internal()
   return obj;
 }
 
-/* new_text_object() allocates a new zeroed text_object */
-static struct text_object *new_text_object()
-{
-       text_object_count++;
-       text_objects = (struct text_object *) realloc(text_objects,
-                                                     sizeof(struct
-                                                            text_object) *
-                                                     text_object_count);
-       memset(&text_objects[text_object_count - 1], 0,
-              sizeof(struct text_object));
-
-       return &text_objects[text_object_count - 1];
-}
-
 #ifdef MLDONKEY
 void ml_cleanup()
 {
@@ -1054,8 +1066,7 @@ static void free_text_objects(unsigned int count, struct text_object *objs)
                        free(objs[i].data.tail.logfile);
                        free(objs[i].data.tail.buffer);
                        break;
-               case OBJ_text:
-               case OBJ_font:
+               case OBJ_text: case OBJ_font:
                        free(objs[i].data.s);
                        break;
                case OBJ_exec:
@@ -1083,6 +1094,14 @@ static void free_text_objects(unsigned int count, struct text_object *objs)
                case OBJ_mpd_status:
                case OBJ_mpd_host:
 #endif
+#ifdef BMPX
+               case OBJ_bmpx_title:
+               case OBJ_bmpx_artist:
+               case OBJ_bmpx_album:
+               case OBJ_bmpx_track:
+               case OBJ_bmpx_uri:
+               case OBJ_bmpx_bitrate:
+#endif
                case OBJ_pre_exec:
                case OBJ_battery:
                        free(objs[i].data.s);
@@ -1129,6 +1148,7 @@ void scan_mixer_bar(const char *arg, int *a, int *w, int *h)
        }
 }
 
+
 /* construct_text_object() creates a new text_object */
 static struct text_object *construct_text_object(const char *s, const char *arg)
 {
@@ -1282,9 +1302,9 @@ if (s[0] == '#') {
                obj->type = OBJ_text;
                snprintf(buf, 256, "${%s}", s);
                obj->data.s = strdup(buf);
-                   } else {
-                           obj->data.execi.cmd = strdup(arg + n);
-                   }
+       } else {
+               obj->data.execi.cmd = strdup(arg + n);
+       }
        END OBJ(execi, 0) unsigned int n;
 
        if (!arg
@@ -1791,6 +1811,39 @@ int a = stippled_borders, b = 1;
         (void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
        END
 #endif
+#ifdef BMPX
+       OBJ(bmpx_title, INFO_BMPX)
+       END
+       OBJ(bmpx_artist, INFO_BMPX)
+       END
+       OBJ(bmpx_album, INFO_BMPX)
+       END
+       OBJ(bmpx_track, INFO_BMPX)
+       END
+       OBJ(bmpx_uri, INFO_BMPX)
+       END
+       OBJ(bmpx_bitrate, INFO_BMPX)
+       END
+#endif
+#ifdef INFOPIPE
+       OBJ(infopipe_protocol, INFO_INFOPIPE) END
+       OBJ(infopipe_version, INFO_INFOPIPE) END
+       OBJ(infopipe_status, INFO_INFOPIPE) END
+       OBJ(infopipe_playlist_tunes, INFO_INFOPIPE) END
+       OBJ(infopipe_playlist_currtune, INFO_INFOPIPE) END
+       OBJ(infopipe_usec_position, INFO_INFOPIPE) END
+       OBJ(infopipe_position, INFO_INFOPIPE) END
+       OBJ(infopipe_usec_time, INFO_INFOPIPE) END
+       OBJ(infopipe_time, INFO_INFOPIPE) END
+       OBJ(infopipe_bitrate, INFO_INFOPIPE) END
+       OBJ(infopipe_frequency, INFO_INFOPIPE) END
+       OBJ(infopipe_channels, INFO_INFOPIPE) END
+       OBJ(infopipe_title, INFO_INFOPIPE) END
+       OBJ(infopipe_file, INFO_INFOPIPE) END
+       OBJ(infopipe_bar, INFO_INFOPIPE) 
+           (void) scan_bar(arg, &obj->a, &obj->b);
+       END
+#endif
 #ifdef TCP_PORT_MONITOR
        OBJ(tcp_portmon, INFO_TCP_PORT_MONITOR) 
                int argc, port_begin, port_end, item, connection_index;
@@ -1904,33 +1957,6 @@ static struct text_object *create_plain_text(const char *s)
   return obj;
 }
 
-/* append_text() appends text to last text_object if it's text, if it isn't
- * it creates a new text_object  [DEPRECATED] 
-*/
-static void append_text(const char *s)
-{
-       struct text_object *obj;
-
-       if (s == NULL || *s == '\0')
-               return;
-
-       obj = text_object_count ? &text_objects[text_object_count - 1] : 0;
-
-       /* create a new text object? */
-       if (!obj || obj->type != OBJ_text) {
-               obj = new_text_object();
-               obj->type = OBJ_text;
-               obj->data.s = strdup(s);
-       } else {
-               /* append */
-               obj->data.s = (char *) realloc(obj->data.s,
-                                              strlen(obj->data.s) +
-                                              strlen(s) + 1);
-               strcat(obj->data.s, s);
-       }
-}
-
-
 static struct text_object_list *extract_variable_text_internal(const char *p)
 {
     struct text_object_list *retval;
@@ -2023,8 +2049,6 @@ static struct text_object_list *extract_variable_text_internal(const char *p)
                                                   obj, sizeof(struct text_object));
                                            free(obj);
                                        }
-
-                                       
                                }
                                continue;
                        } else {
@@ -2039,16 +2063,13 @@ static struct text_object_list *extract_variable_text_internal(const char *p)
                                free(obj);
                            }
                        }
-
                }
-
                p++;
        }
-
        obj = create_plain_text(s);
        if(obj != NULL) {
            // allocate memory for the object
-           retval->text_objects = realloc(retval->text_objects, 
+           retval->text_objects = realloc(retval->text_objects,
                                           sizeof(struct text_object) * (retval->text_object_count+1));
            // assign the new object to the end of the list.
            memcpy(&retval->text_objects[retval->text_object_count++],
@@ -2077,13 +2098,18 @@ static void extract_variable_text(const char *p)
          
   list = extract_variable_text_internal(p);
   text_objects = list->text_objects;
-  text_object_count = list->text_object_count;  
+  text_object_count = list->text_object_count;
 
   free(list);
 
   return;
 }
 
+void parse_conky_vars(char * text, char * p, struct information *cur) { 
+       struct text_object_list *object_list = extract_variable_text_internal(text);
+       generate_text_internal(p, P_MAX_SIZE, object_list->text_objects, object_list->text_object_count, cur);
+       free(object_list);
+}
 
 static void generate_text_internal(char *p, int p_max_size, struct text_object *objs, unsigned int object_count, struct information *cur)
 {
@@ -2358,30 +2384,20 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                        }
 
                        OBJ(exec) {
-                               char *output = p;
                                FILE *fp = popen(obj->data.s, "r");
                                int length = fread(p, 1, p_max_size, fp);
                                (void) pclose(fp);
-                                   
-                               output[length] = '\0';
+
+                               /*output[length] = '\0';
                                if (length > 0 && output[length - 1] == '\n') {
                                        output[length - 1] = '\0';
-                               }
+                               }*/
+                                       p[length] = '\0';
+                                       if (length > 0 && p[length - 1] == '\n') {
+                                               p[length - 1] = '\0';
+                                       }
                                    
-                               struct text_object_list *object_list = extract_variable_text_internal(output);
-                               generate_text_internal(p, length, object_list->text_objects, object_list->text_object_count, cur);
-                               free(object_list);
-/* DaC
-                               p[n2] = '\0';
-                               if (n2 && p[n2 - 1] == '\n')
-                                       p[n2 - 1] = '\0';
-
-                               while (*p2) {
-                                       if (*p2 == '\001')
-                                               *p2 = ' ';
-                                       p2++;
-                               } 
-*/
+                               //parse_conky_vars(output, p, cur);
                        }
                        OBJ(execbar) {
                                char *p2 = p;
@@ -2438,7 +2454,7 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
 
                        }
                        OBJ(execibar) {
-                               if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
+                               if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
                                        new_bar(p, 0, 4, (int) obj->f);
                                } else {
                                        char *p2 = p;
@@ -2469,7 +2485,7 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                }
                        }
                        OBJ(execigraph) {
-                               if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
+                               if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
                                        new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->f), 100, 0);
                                } else {
                                        char *p2 = p;
@@ -2501,63 +2517,44 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
 
                        }
                        OBJ(execi) {
-                               if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
-                                   snprintf(p, p_max_size, "%s", obj->data.execi.buffer);
+                               if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval || obj->data.execi.interval == 0) {
+                                       snprintf(p, p_max_size, "%s", obj->data.execi.buffer);
                                } else {
-                                   char *output = obj->data.execi.buffer;
-                                   FILE *fp = popen(obj->data.execi.cmd, "r");
-                                   int length = fread(output, 1, TEXT_BUFFER_SIZE, fp);
-                                   (void) pclose(fp);
-                                   
-                                   output[length] = '\0';
-                                   if (length > 0 && output[length - 1] == '\n')
-                                       output[length - 1] = '\0';
-                                   
-                                   struct text_object_list *object_list = extract_variable_text_internal(output);
-                                   generate_text_internal(p, length, object_list->text_objects, object_list->text_object_count, cur);
-                                   free(object_list);
-                                                                           
-                                   /*
-                                       char *p2 = obj->data.execi.buffer;
+                                       char *output = obj->data.execi.buffer;
                                        FILE *fp = popen(obj->data.execi.cmd, "r");
-                                       int n2 = fread(p2, 1, TEXT_BUFFER_SIZE, fp);
+                                       //int length = fread(output, 1, TEXT_BUFFER_SIZE, fp);
+                                       int length = fread(output, 1, TEXT_BUFFER_SIZE, fp);
                                        (void) pclose(fp);
-
-                                       p2[n2] = '\0';
-                                       if (n2 && p2[n2 - 1] == '\n')
-                                               p2[n2 - 1] = '\0';
-
-                                       while (*p2) {
-                                         if (*p2 == '\001') {
-                                           *p2 = ' ';
-                                         } else if(*p2 == '$') {
-                                             //memset(*t, 0, sizeof(struct text_object));
-                                         }
-                                         p2++;
+                                   
+                                       output[length] = '\0';
+                                       if (length > 0 && output[length - 1] == '\n') {
+                                               output[length - 1] = '\0';
                                        }
-
-                                       snprintf(p, p_max_size, "%s", obj->data.execi.buffer);
-                                       obj->data.execi.last_update = current_update_time;*/
+                                       obj->data.execi.last_update = current_update_time;
+                                       snprintf(p, p_max_size, "%s", output);
                                }
+                               //parse_conky_vars(output, p, cur);
                        }
                        OBJ(texeci) {
                                static int running = 0;
-                               if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
+                               if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
                                        snprintf(p, p_max_size, "%s", obj->data.execi.buffer);
                                } else {
                                        static pthread_t execthread;
+                                       if (running) {
+                                               pthread_join( execthread, NULL);
+                                               running = 0;
+                                       }
                                        if (!running) {
                                                running = 1;
                                                pthread_create( &execthread, NULL, (void*)threaded_exec, (void*) obj);
                                                pthread_mutex_lock( &mutex1 );
                                                obj->data.execi.last_update = current_update_time;
                                                pthread_mutex_unlock( &mutex1 );
-                                       } else {
-                                               pthread_join( execthread, NULL);
-                                               running = 0;
                                        }
                                        snprintf(p, p_max_size, "%s", obj->data.execi.buffer);
                                }
+                               //parse_conky_vars(obj->data.execi.buffer, p, cur);
                        }
 #endif
                        OBJ(fs_bar) {
@@ -3102,6 +3099,76 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                               255.0f));
                        }
 #endif
+#ifdef BMPX
+                       OBJ(bmpx_title) {
+                               snprintf(p, p_max_size, "%s", cur->bmpx.title);
+                       }
+                       OBJ(bmpx_artist) {
+                               snprintf(p, p_max_size, "%s", cur->bmpx.artist);
+                       }
+                       OBJ(bmpx_album) {
+                               snprintf(p, p_max_size, "%s", cur->bmpx.album);
+                       }
+                       OBJ(bmpx_uri) {
+                               snprintf(p, p_max_size, "%s", cur->bmpx.uri);
+                       }
+                       OBJ(bmpx_track) {
+                                snprintf(p, p_max_size, "%i", cur->bmpx.track);
+                       }
+                       OBJ(bmpx_bitrate) {
+                               snprintf(p, p_max_size, "%i", cur->bmpx.bitrate);
+                       }
+#endif
+#ifdef INFOPIPE
+                        OBJ(infopipe_protocol) {
+                               snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_PROTOCOL]);
+                       }
+                        OBJ(infopipe_version) {
+                               snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_VERSION]);
+                       }
+                        OBJ(infopipe_status) {
+                               snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_STATUS]);
+                       }
+                        OBJ(infopipe_playlist_tunes) {
+                               snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_PLAYLIST_TUNES]);
+                       }
+                        OBJ(infopipe_playlist_currtune) {
+                               snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_PLAYLIST_CURRTUNE]);
+                       }
+                        OBJ(infopipe_usec_position) {
+                               snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_USEC_POSITION]);
+                       }
+                        OBJ(infopipe_position) {
+                               snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_POSITION]);
+                       }
+                        OBJ(infopipe_usec_time) {
+                               snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_USEC_TIME]);
+                       }
+                        OBJ(infopipe_time) {
+                               snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_TIME]);
+                       }
+                        OBJ(infopipe_bitrate) {
+                               snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_BITRATE]);
+                       }
+                        OBJ(infopipe_frequency) {
+                               snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_FREQUENCY]);
+                       }
+                        OBJ(infopipe_channels) {
+                               snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_CHANNELS]);
+                       }
+                        OBJ(infopipe_title) {
+                               snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_TITLE]);
+                       }
+                        OBJ(infopipe_file) {
+                               snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_FILE]);
+                       }
+                       OBJ(infopipe_bar) {
+                               double progress;
+                               progress= atof(cur->infopipe.items[INFOPIPE_USEC_POSITION]) /
+                                         atof(cur->infopipe.items[INFOPIPE_USEC_TIME]);
+                               new_bar(p,obj->a,obj->b,(int)(progress*255.0f));
+                       }
+#endif
                        OBJ(top) {
                                if (obj->data.top.type == TOP_NAME
                                    && obj->data.top.num >= 0
@@ -3161,18 +3228,8 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                        }
 
 
-
-                       /*
-                        * I'm tired of everything being packed in
-                        * pee
-                        * poop
-                        */
-
-
                        OBJ(tail) {
-                               if (current_update_time -obj->data.tail.last_update < obj->data.tail.interval) {
-                                       snprintf(p, p_max_size, "%s", obj->data.tail.buffer);
-                               } else {
+                               if (current_update_time -obj->data.tail.last_update >= obj->data.tail.interval) {
                                        obj->data.tail.last_update = current_update_time;
                                        FILE *fp;
                                        int i;
@@ -3221,21 +3278,19 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                                        if (obj->data.tail.buffer[strlen(obj->data.tail.buffer)-1] == '\n') {
                                                                obj->data.tail.buffer[strlen(obj->data.tail.buffer)-1] = '\0';
                                                        }
-                                                       snprintf(p, p_max_size, "%s", obj->data.tail.buffer);
 
                                                        freetail(freetmp);
-                                               }
-                                               else {
+                                               } else {
                                                        strcpy(obj->data.tail.buffer, "Logfile Empty");
-                                                       snprintf(p, p_max_size, "Logfile Empty");
-                                               }
-                                       }
-                               }
+                                               }  /* if readlines */
+                                       } /*  fp == NULL  */
+                               } /* if cur_upd_time >= */
+       
+                               //parse_conky_vars(obj->data.tail.buffer, p, cur);
+
                        }
                        OBJ(head) {
-                               if (current_update_time -obj->data.tail.last_update < obj->data.tail.interval) {
-                                       snprintf(p, p_max_size, "%s", obj->data.tail.buffer);
-                               } else {
+                               if (current_update_time -obj->data.tail.last_update >= obj->data.tail.interval) {
                                        obj->data.tail.last_update = current_update_time;
                                        FILE *fp;
                                        tailstring *head = NULL;
@@ -3244,8 +3299,7 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                        fp = fopen(obj->data.tail.logfile, "rt");
                                        if (fp == NULL) {
                                                ERR("head logfile failed to open");
-                                       }
-                                       else {
+                                       } else {
                                                obj->data.tail.readlines = 0;
                                                while (fgets(obj->data.tail.buffer, TEXT_BUFFER_SIZE*20, fp) != NULL && obj->data.tail.readlines <= obj->data.tail.wantedlines) {
                                                        addtail(&head, obj->data.tail.buffer);
@@ -3271,14 +3325,14 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                                        if (obj->data.tail.buffer[strlen(obj->data.tail.buffer)-1] == '\n') {
                                                                obj->data.tail.buffer[strlen(obj->data.tail.buffer)-1] = '\0';
                                                        }
-                                                       snprintf(p, p_max_size, "%s", obj->data.tail.buffer);
-                                               }
-                                               else {
+                                               } else {
                                                        strcpy(obj->data.tail.buffer, "Logfile Empty");
-                                                       snprintf(p, p_max_size, "Logfile Empty");
-                                               }
-                                       }
-                               }
+                                               } /* if readlines > 0 */
+                                       } /* if fp == null */
+                               } /* cur_upd_time >= */
+
+                               //parse_conky_vars(obj->data.tail.buffer, p, cur);
+
                        }
 #ifdef TCP_PORT_MONITOR
                        OBJ(tcp_portmon)
@@ -3321,7 +3375,6 @@ double current_update_time, last_update_time;
 
 static void generate_text()
 {
-       unsigned int n;
        struct information *cur = &info;
        char *p;
 
@@ -3333,12 +3386,13 @@ static void generate_text()
 
        update_stuff(cur);
 
+       /* add things to the buffer */
+
        /* generate text */
 
-       n = TEXT_BUFFER_SIZE * 4 - 2;
        p = text_buffer;
 
-       generate_text_internal(p, n, text_objects, text_object_count, cur);
+       generate_text_internal(p, P_MAX_SIZE, text_objects, text_object_count, cur);
 
        if (stuff_in_upper_case) {
                char *p;
@@ -3593,6 +3647,7 @@ static void draw_string(const char *s)
        width_of_s = get_string_width(s);
        if (out_to_console) {
                printf("%s\n", s);
+               fflush(stdout);   /* output immediately, don't buffer */
        }
        /* daemon_run(s);  the daemon can be called here, but we need to have a buffer in daemon_run() and we need to tell it when everything is ready to be sent */
        memset(tmpstring1,0,TEXT_BUFFER_SIZE);
@@ -3939,15 +3994,10 @@ static void draw_line(char *s)
                                                w = text_start_x + text_width - cur_x - 1;
                                        if (w < 0)
                                                w = 0;
-                                       XSetLineAttributes(display,
-                                                          window.gc, 1,
-                                                          LineSolid,
-                                                          CapButt,
-                                                          JoinMiter);
-                                       XDrawRectangle(display,
-                                                      window.drawable,
-                                                      window.gc, cur_x,
-                                                      by, w, h);
+                                       if (draw_graph_borders) {
+                                               XSetLineAttributes(display, window.gc, 1, LineSolid, CapButt, JoinMiter);
+                                               XDrawRectangle(display,window.drawable, window.gc, cur_x, by, w, h);
+                                       }
                                        XSetLineAttributes(display,
                                                           window.gc, 1,
                                                           LineSolid,
@@ -4628,8 +4678,9 @@ static void set_default_configurations(void)
        default_fg_color = WhitePixel(display, screen);
        default_bg_color = BlackPixel(display, screen);
        default_out_color = BlackPixel(display, screen);
-       draw_borders = 0;
        draw_shades = 1;
+       draw_borders = 0;
+       draw_graph_borders = 1;
        draw_outline = 0;
        set_first_font("6x10");
        gap_x = 5;
@@ -4853,6 +4904,9 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
                CONF("draw_borders") {
                        draw_borders = string_to_bool(value);
                }
+               CONF("draw_graph_borders") {
+                       draw_graph_borders = string_to_bool(value);
+               }
                CONF("draw_shades") {
                        draw_shades = string_to_bool(value);
                }
@@ -4872,12 +4926,10 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
                        use_xft = string_to_bool(value);
                }
                CONF("font") {
-                       if (!use_xft) {
-                               if (value) {
-                                       set_first_font(value);
-                               } else
-                                       CONF_ERR;
-                       }
+                       if (value) {
+                               set_first_font(value);
+                       } else
+                               CONF_ERR;
                }
                CONF("xftalpha") {
                        if (value && font_count >= 0)
@@ -4900,10 +4952,12 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
                }
                CONF("font") {
 #endif
-                       if (value) {
-                               set_first_font(value);
-                       } else
-                               CONF_ERR;
+                       if (use_xft) {
+                               if (value) {
+                                       set_first_font(value);
+                               } else
+                                       CONF_ERR;
+                       }
                }
                CONF("gap_x") {
                        if (value)
@@ -5425,7 +5479,40 @@ int main(int argc, char **argv)
                ERR("error setting signal handler: %s", strerror(errno) );
        }
 
+#ifdef INFOPIPE
+       /* joinable thread for infopipe activity */
+        pthread_attr_init(&info.infopipe.thread_attr);
+       pthread_attr_setdetachstate(&info.infopipe.thread_attr, PTHREAD_CREATE_JOINABLE);
+       /* init mutexex */
+       pthread_mutex_init(&info.infopipe.item_mutex, NULL);
+       pthread_mutex_init(&info.infopipe.runnable_mutex, NULL);
+       /* init runnable condition for worker thread */
+       pthread_mutex_lock(&info.infopipe.runnable_mutex);
+       info.infopipe.runnable=1;
+       pthread_mutex_unlock(&info.infopipe.runnable_mutex);
+       if (pthread_create(&info.infopipe.thread, &info.infopipe.thread_attr, infopipe_thread_func, NULL))
+       {
+           CRIT_ERR("unable to create infopipe thread!");
+       }
+#endif
+
        main_loop();
+       
+#ifdef INFOPIPE
+       /* signal infopipe worker thread to terminate */
+       pthread_mutex_lock(&info.infopipe.runnable_mutex);
+       info.infopipe.runnable=0;
+       pthread_mutex_unlock(&info.infopipe.runnable_mutex);
+       /* destroy thread attribute and wait for thread */
+       pthread_attr_destroy(&info.infopipe.thread_attr);
+       if (pthread_join(info.infopipe.thread, NULL))
+       {
+           ERR("error joining infopipe thread");
+        }
+       /* destroy mutexes */
+       pthread_mutex_destroy(&info.infopipe.item_mutex);
+       pthread_mutex_destroy(&info.infopipe.runnable_mutex);
+#endif
 
        return 0;
 }