diff --git a/TODO b/TODO
index ce036c8..6df6aea 100644
--- a/TODO
+++ b/TODO
@@ -1,2 +1,3 @@
 - Add uicb for sel->border++-- and awesomeconf->border++--
 - Move windows from one place to another with mouse in tiled layout
+- draw _NET_WM_ICON
diff --git a/config.mk b/config.mk
index 603bb0d..e7508f0 100644
--- a/config.mk
+++ b/config.mk
@@ -18,7 +18,7 @@ INCS = -I. -I/usr/include -I${X11INC} `pkg-config --cflags libconfig`
 LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 `pkg-config --libs libconfig` -lXext -lXrandr -lXinerama
 
 # flags
-CFLAGS = -fgnu89-inline -std=gnu99 -ggdb3 -pipe -Wall -Wextra -W -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wsign-compare -Wunused -Wuninitialized -Winit-self -Wpointer-arith -Wredundant-decls -Wno-format-zero-length -Wmissing-prototypes -Wmissing-format-attribute -Wmissing-noreturn -O3 ${INCS} -DVERSION=\"${VERSION}\"
+CFLAGS = -fgnu89-inline -std=gnu99 -ggdb3 -pipe -Wall -Wextra -W -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wsign-compare -Wunused -Wuninitialized -Winit-self -Wpointer-arith -Wredundant-decls -Wno-format-zero-length -Wmissing-prototypes -Wmissing-format-attribute -Wmissing-noreturn -O0 ${INCS} -DVERSION=\"${VERSION}\"
 LDFLAGS = -ggdb3 ${LIBS}
 
 # compiler and linker
diff --git a/draw.c b/draw.c
index 92f6b40..7eb599c 100644
--- a/draw.c
+++ b/draw.c
@@ -19,9 +19,13 @@
  * 
  */
 
+#include <X11/Xmd.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+
 #include "layout.h"
-#include "util.h"
 #include "draw.h"
+#include "util.h"
 
 extern Client *clients, *sel, *stack;   /* global client list and stack */
 
@@ -93,6 +97,117 @@ drawsquare(Bool filled, Bool empty, unsigned long col[ColLast], Display *disp, D
     }
 }
 
+void
+drawicon(Display *disp, int screen, DC * drawcontext, Statusbar *statusbar)
+{
+    unsigned char *udata = NULL, *icondata, *p, r, g, b, alpha;
+    /* XXX 32 or 64 ? maybe arch dependent !? how to know ?!*/
+    CARD64 *data;
+    int i, r_format;
+    Atom r_type;
+    unsigned long read = 0, left, pixel;
+    unsigned int width, height, x, y;
+    long expected = 2;
+    XImage *ximage;
+    Pixmap pix = None;
+
+    if((XGetWindowProperty(disp, sel->win, XInternAtom(disp, "_NET_WM_ICON", False), 0L, expected,
+                           False, XA_CARDINAL, &r_type, &r_format, &read, &left, &udata) != Success || read == 0))
+    {
+        if(udata)
+            XFree(udata);
+        return;
+    }
+
+    data = (CARD64 *) udata;
+
+    width = data[0];
+    height = data[1];
+
+    expected = width * height;
+
+    if((XGetWindowProperty(disp, sel->win, XInternAtom(disp, "_NET_WM_ICON", False), 2L, expected,
+                           False, XA_CARDINAL, &r_type, &r_format, &read, &left, &udata) != Success || read == 0))
+    {
+        if(udata)
+            XFree(udata);
+        return;
+    }
+
+    data = (CARD64 *) udata;
+
+    icondata = p_new(unsigned char, width * height * 4);
+    p = icondata;
+
+/*    for(i = 2; i < expected; i += 1)
+    {
+        *p++ = data[i] >> 16 & 0xff;
+        *p++ = data[i] >> 8 & 0xff;
+        *p++ = data[i] & 0xff;
+        *p++ = data[i] >> 24 & 0xff;
+    } */
+
+    ximage = XCreateImage(disp, DefaultVisual(disp, screen), DefaultDepth(disp, screen),
+                          ZPixmap, 0, NULL, width, height, 32, 0);
+
+//    ximage->data = p_new(char, ximage->bytes_per_line * height / sizeof(char));
+    ximage->data = (char *) udata;
+    p = icondata;
+
+/*    for(x = 0; x < width * height; x++)
+    {
+            r = *p++;
+            g = *p++;
+            b = *p++;
+            *p += 1; */
+
+/*    for(y = 0; y < height; ++y)
+    {
+        for(x = 0; x < width; ++x)
+        {
+            r = *p++;
+            g = *p++;
+            b = *p++;
+            *p += 1;
+
+            // 5 R, 5 G, 5 B (15 bit display)
+/*            if ((ximage->red_mask == 0x7c00)
+                && (ximage->green_mask == 0x3e0) && (ximage->blue_mask == 0x1f))
+                pixel = ((r << 7) & 0x7c00) | ((g << 2) & 0x03e0) | ((b >> 3) & 0x001f);
+            // 5 R, 6 G, 5 B (16 bit display)
+            else  if ((ximage->red_mask == 0xf800)
+                      && (ximage->green_mask == 0x07e0)
+                      && (ximage->blue_mask == 0x001f))
+                pixel = ((r << 8) &  0xf800) | ((g << 3) & 0x07e0) | ((b >> 3) & 0x001f);
+            else if  ((ximage->red_mask == 0xff0000)
+                      && (ximage->green_mask == 0xff00)
+                      && (ximage->blue_mask == 0xff))
+                pixel = ((r << 16) & 0xff0000) | ((g << 8) & 0x00ff00) | (b & 0x0000ff);
+            else
+                pixel = 0;*/
+
+
+//            XPutPixel(ximage, x, y, pixel);
+//
+            /*  ximage->data[x*y+0] = r;
+              ximage->data[x*y+1] = g;
+              ximage->data[x*y+2] = b; */
+
+//        }
+ //   }
+
+    pix = XCreatePixmap(disp, RootWindow(disp, screen), width, height, DefaultDepth(disp, screen));
+    XPutImage(disp, pix, drawcontext->gc, ximage, 0, 0, 0, 0, width, height);
+
+    XCopyArea(disp, pix, statusbar->drawable, drawcontext->gc, 0, 0, width, statusbar->height, 0, 0);
+
+//    p_delete(&ximage->data);
+    ximage->data = NULL;
+    XDestroyImage(ximage);
+    p_delete(&icondata);
+//    XFree(data);
+}
+
 unsigned int
 textnw(XFontSet set, XFontStruct *xfont, const char *text, unsigned int len)
 {
diff --git a/draw.h b/draw.h
index b05e772..331afad 100644
--- a/draw.h
+++ b/draw.h
@@ -28,6 +28,7 @@
 
 void drawsquare(Bool, Bool, unsigned long *, Display *, DC, Statusbar *);
 void drawtext(Display *, DC, Drawable, const char *, unsigned long *);
+void drawicon(Display *, int, DC *, Statusbar *);
 unsigned int textnw(XFontSet, XFontStruct *, const char *, unsigned int);
 
 #endif
diff --git a/statusbar.c b/statusbar.c
index ec803b2..0ea889f 100644
--- a/statusbar.c
+++ b/statusbar.c
@@ -82,6 +82,7 @@ drawstatusbar(Display *disp, int screen, DC *drawcontext, awesome_config * aweso
         {
             drawtext(disp, *drawcontext, awesomeconf->statusbar.drawable, sel->name, drawcontext->sel);
             drawsquare(sel->ismax, sel->isfloating, drawcontext->sel, disp, *drawcontext, &awesomeconf->statusbar);
+            drawicon(disp, screen, drawcontext, &awesomeconf->statusbar);
         }
         else
             drawtext(disp, *drawcontext, awesomeconf->statusbar.drawable, NULL, drawcontext->norm);
