lol
[monky] / src / conky.c
index 7dfce67..ff33b82 100644 (file)
 /* #define SIGNAL_BLOCKING */
 #undef SIGNAL_BLOCKING
 
+static void print_version()
+{
+       printf("Conky %s compiled %s for %s\n",
+                       VERSION, BUILD_DATE, BUILD_ARCH);
+
+       printf(
+       "\nCompiled in features:\n\n"
+#ifdef X11
+       " X11:\n"
+# ifdef XFT
+       "  * xft\n"
+# endif /* XFT */
+# ifdef HAVE_XDAMAGE
+       "  * Xdamage extension\n"
+# endif /* HAVE_XDAMAGE */
+# ifdef HAVE_XDBE
+       "  * Xdbe extension (double buffer)\n"
+# endif /* HAVE_XDBE */
+#endif /* X11 */
+       "\n Music detection:\n"
+#ifdef XMMS
+       "  * xmms\n"
+#endif /* XMMS */
+#ifdef BMP
+       "  * bmp\n"
+#endif /* BMP */
+#ifdef AUDACIOUS
+       "  * audacious\n"
+#endif /* AUDACIOUS */
+#ifdef INFOPIPE
+       "  * infopipe\n"
+#endif /* INFOPIPE */
+#ifdef BMPX
+       "  * bmpx\n"
+#endif /* BMPX */
+#ifdef XMMS2
+       "  * xmms2\n"
+#endif /* XMMS2 */
+#ifdef MPD
+       "  * mpd\n"
+#endif /* MPD */
+       "\n General features:\n"
+#ifdef TCP_PORT_MONITOR
+       "  * portmon\n"
+#endif /* TCP_PORT_MONITOR */
+#ifdef MLDONKEY
+       "  * mldonkey\n"
+#endif /* MLDONKEY */
+#ifdef HDDTEMP
+        "  * hddtemp\n"
+#endif /* HDDTEMP */
+#ifdef SETI
+       "  * seti\n"
+#endif /* SETI*/
+       "\n");  
+
+       exit(0);
+}
+
 #ifdef X11
 
 /*
@@ -106,13 +165,6 @@ struct font_list *fonts = NULL;
 
 static void set_font();
 
-static void print_version()
-{
-       printf("Conky %s compiled %s for %s\n",
-                       VERSION, BUILD_DATE, BUILD_ARCH);
-       exit(0);
-}
-
 int addfont(const char *data_in)
 {
        if (font_count > MAX_FONTS) {
@@ -276,7 +328,7 @@ static int fixed_size = 0, fixed_pos = 0;
 static int minimum_width, minimum_height;
 static int maximum_width;
 
-
+#endif /* X11 */
 
 #ifdef HAVE_ICONV
 #define CODEPAGE_LENGTH 20
@@ -324,8 +376,6 @@ void free_iconv(void)
 /* UTF-8 */
 int utf8_mode = 0;
 
-#endif /* X11 */
-
 /* no buffers in used memory? */
 int no_buffers;
 
@@ -424,9 +474,9 @@ static inline int calc_text_width(const char *s, int l)
        if (use_xft) {
                XGlyphInfo gi;
                if (utf8_mode) {
-                       XftTextExtentsUtf8(display, fonts[selected_font].xftfont, s, l, &gi);
+                       XftTextExtentsUtf8(display, fonts[selected_font].xftfont, (FcChar8 *)s, l, &gi);
                } else {
-                       XftTextExtents8(display, fonts[selected_font].xftfont, s, l, &gi);
+                       XftTextExtents8(display, fonts[selected_font].xftfont, (FcChar8 *)s, l, &gi);
                }
                return gi.xOff;
        } else
@@ -3270,12 +3320,12 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                }
                                OBJ(freq) {
                                        if (obj->a) {
-                                               obj->a = get_freq(p, p_max_size, "%.0f", 1, obj->data.cpu_index); /* pk */
+                                               obj->a = get_freq(p, p_max_size, "%.0f", 1, obj->data.cpu_index); 
                                        }
                                }
                                OBJ(freq_g) {
                                        if (obj->a) {
-                                               obj->a = get_freq(p, p_max_size, "%'.2f", 1000, obj->data.cpu_index); /* pk */
+                                               obj->a = get_freq(p, p_max_size, "%'.2f", 1000, obj->data.cpu_index); 
                                        }
                                }
 #if defined(__linux__)
@@ -3293,29 +3343,29 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
 
                                OBJ(freq_dyn) {
                                        if (use_spacer) {
-                                               get_freq_dynamic(p, 6, "%.0f     ", 1 ); /* pk */
+                                               get_freq_dynamic(p, 6, "%.0f     ", 1 ); 
                                        } else {
-                                               get_freq_dynamic(p, p_max_size, "%.0f", 1 ); /* pk */
+                                               get_freq_dynamic(p, p_max_size, "%.0f", 1 ); 
                                        }
                                }
                                OBJ(freq_dyn_g) {
                                        if (use_spacer) {
-                                               get_freq_dynamic(p, 6, "%'.2f     ", 1000); /* pk */
+                                               get_freq_dynamic(p, 6, "%'.2f     ", 1000); 
                                        } else {
-                                               get_freq_dynamic(p, p_max_size, "%'.2f", 1000); /* pk */
+                                               get_freq_dynamic(p, p_max_size, "%'.2f", 1000); 
                                        }
                                }
                                OBJ(adt746xcpu) {
-                                       get_adt746x_cpu(p, p_max_size); /* pk */
+                                       get_adt746x_cpu(p, p_max_size); 
                                }
                                OBJ(adt746xfan) {
-                                       get_adt746x_fan(p, p_max_size); /* pk */
+                                       get_adt746x_fan(p, p_max_size); 
                                }
                                OBJ(acpifan) {
-                                       get_acpi_fan(p, p_max_size);  /* pk */
+                                       get_acpi_fan(p, p_max_size);  
                                }
                                OBJ(acpiacadapter) {
-                                       get_acpi_ac_adapter(p, p_max_size); /* pk */
+                                       get_acpi_ac_adapter(p, p_max_size); 
                                }
                                OBJ(battery) {
                                        get_battery_stuff(p, p_max_size, obj->data.s);
@@ -4940,9 +4990,8 @@ static void update_text_area()
                text_width = minimum_width;
                text_height = 0;
                special_index = 0;
-               int first_font_height = last_font_height = font_height();
+               last_font_height = font_height();
                for_each_line(text_buffer, text_size_updater);
-               text_height -= first_font_height;
                text_width += 1;
                if (text_height < minimum_height)
                        text_height = minimum_height;
@@ -5720,7 +5769,7 @@ static void main_loop()
 #endif /* X11 */
 
        info.looped = 0;
-       while (total_run_times == 0 || info.looped < total_run_times - 1) {
+       while (total_run_times == 0 || info.looped < total_run_times) {
                info.looped++;
 
 #ifdef SIGNAL_BLOCKING
@@ -5935,13 +5984,15 @@ static void main_loop()
                                        XDamageNotifyEvent  *dev = (XDamageNotifyEvent *) &ev;
                                        XFixesSetRegion(display, part, &dev->area, 1);
                                        XFixesUnionRegion(display, region2, region2, part);
-                                       XDamageSubtract(display, damage, region2, None);
-                                       XFixesSetRegion(display, region2, 0, 0);
                                }
 #endif /* HAVE_XDAMAGE */
                                break;
                        }
-               }
+       }
+#ifdef HAVE_XDAMAGE
+               XDamageSubtract(display, damage, region2, None);
+               XFixesSetRegion(display, region2, 0, 0);
+#endif /* HAVE_XDAMAGE */
 
                /* XDBE doesn't seem to provide a way to clear the back buffer without
                 * interfering with the front buffer, other than passing XdbeBackground
@@ -6855,19 +6906,23 @@ int main(int argc, char **argv)
                
        /* handle command line parameters that don't change configs */
 #ifdef X11
-       char *s;
-       char temp[10];
+       char *s, *temp;
        unsigned int x;
 
        if (((s = getenv("LC_ALL")) && *s) || ((s = getenv("LC_CTYPE")) && 
                     *s) || ((s = getenv("LANG")) && *s)) {
-               strcpy(temp, s);
-               for(x = 0; x < strlen(s) ; x++) {
+               temp = (char *)malloc((strlen(s) + 1) * sizeof(char));
+               if (temp == NULL) {
+                       ERR("malloc failed");
+               }
+               for (x = 0; x < strlen(s); x++) {
                        temp[x] = tolower(s[x]);
                }
                if (strstr(temp, "utf-8") || strstr(temp, "utf8")) {
                        utf8_mode = 1;
                }
+               
+               free(temp);
        }
        if (!setlocale(LC_CTYPE, "")) {
                ERR("Can't set the specified locale!\nCheck LANG, LC_CTYPE, LC_ALL.");
@@ -7155,6 +7210,6 @@ void signal_handler(int sig)
 {
        /* signal handler is light as a feather, as it should be. 
         * we will poll g_signal_pending with each loop of conky
-        * and do any signal processing there, NOT here.  pkovacs. */
+        * and do any signal processing there, NOT here. */
        g_signal_pending=sig;
 }