diff --git a/README b/README
index 0f33f48d67c3e8bbe9ed824059c86bd9e40fccba..c93451813c7e2ffd3c1e8c0c767d5eb5c0cb1e46 100644
--- a/README
+++ b/README
@@ -51,6 +51,8 @@ You can also add attributes to the message (written as command-line options):
 
   --slider=p		Draw a line with a slider (p=0..100)
 
+  --to=stdout		Write message to stdout instead of display.
+
 The default values of most of these attributes can be given by command-line
 options of the daemon, use `osdd --help' to get the full list.
 
diff --git a/osdd.c b/osdd.c
index a3364fc8526306a91996b5fdd65a551b3d78a9cf..0da7712165c115a62ce32e35982b9a735353318e 100644
--- a/osdd.c
+++ b/osdd.c
@@ -178,7 +178,6 @@ display_msg(struct msg *msg)
 	outline_color = val;
       else if (!strcmp(key, "outline-width"))
 	outline_width = atoi(val);
-
       if (l)
 	{
 	  l->fg_color = fg_color;
@@ -195,6 +194,44 @@ display_msg(struct msg *msg)
   osd_show(osd);
 }
 
+static void
+msg_to_stdout(struct msg *msg)
+{
+  DBG("## Printing message to stdout\n");
+
+  char *line = msg->text;
+  int out_parametr_index=0;
+  while (*line)
+    {
+      // The parser it destructive, but it does not do any harm, since we display each message only once.
+      char *nl = strchr(line, '\n');
+      *nl++ = 0;
+
+      char *key;
+      char *val = strchr(line, ':');
+      if (val)
+	{
+	  key = line;
+	  *val++ = 0;
+	}
+      else
+	{
+	  key = "";
+	  val = line;
+	}
+      DBG("\t%s:%s\n", key, val);
+
+      if (!key[0])
+	{
+		printf(out_parametr_index++?" %s":"%s",val);
+	}
+
+      line = nl;
+    }
+	printf("\n");
+	fflush(stdout);
+}
+
 static void
 hide_msg(struct msg *msg)
 {
@@ -218,12 +255,52 @@ enqueue_msg(unsigned char *buf, int len)
   memcpy(msg->text, buf, len);
   msg->text[len] = 0;
 
-  if (first_msg)
-    last_msg->next = msg;
+  char to[123];
+  *to=0;
+
+  char *line = msg->text;
+  while (*line)
+    {
+      char *nl = strchr(line, '\n');
+      *nl++=0;
+
+      char *key;
+      char *val = strchr(line, ':');
+      if (val)
+	{
+	  key = line;
+	  *val++ = 0;
+	}
+      else
+	{
+	  key = "";
+	  val = line;
+	}
+      DBG("\t%s:%s\n", key, val);
+
+      if (!strcmp(key, "to"))
+      {
+	      if(strlen(val)<120)
+		      strcpy(to,val);
+      }
+
+      val[-1]=':';
+      nl[-1]=10;
+      line = nl;
+    }
+  if(!strcmp(to,"stdout"))
+  {
+	  msg_to_stdout(msg);
+  }
   else
-    first_msg = msg;
-  last_msg = msg;
-  msg->next = NULL;
+  {
+	  if (first_msg)
+	    last_msg->next = msg;
+	  else
+	    first_msg = msg;
+	  last_msg = msg;
+	  msg->next = NULL;
+  }
 }
 
 static void
diff --git a/util.h b/util.h
index f1674acf440b5af42f9baaf66806db38ff8c71fc..957baaf98b525b794816e015dfbe6be9e93fad38 100644
--- a/util.h
+++ b/util.h
@@ -16,7 +16,7 @@ typedef uint64_t timestamp_t;
 void NONRET FORMAT_CHECK(printf,1,2) die(char *fmt, ...);
 
 #ifdef DEBUG
-#define DBG(f...) printf(f)
+#define DBG(f...) fprintf(stderr,f)
 #else
 #define DBG(f...) do { } while(0)
 #endif