diff -r ccb2b92086bf dmenu.c
--- a/dmenu.c	Thu Aug 12 15:35:51 2010 +0100
+++ b/dmenu.c	Fri Aug 13 17:31:14 2010 +0100
@@ -18,9 +18,9 @@
 
 typedef struct Item Item;
 struct Item {
-	char *text;
+	char *text, *value;
+	Item *left, *right;  /* traverses matching items */
 	Item *next;          /* traverses all items */
-	Item *left, *right;  /* traverses matching items */
 };
 
 static void appenditem(Item *item, Item **list, Item **last);
@@ -41,6 +41,7 @@
 static char text[BUFSIZ];
 static size_t cursor = 0;
 static const char *font = NULL;
+static const char *keysep = NULL;
 static const char *prompt = NULL;
 static const char *normbgcolor = "#cccccc";
 static const char *normfgcolor = "#000000";
@@ -293,7 +294,7 @@
 		break;
 	case XK_Return:
 	case XK_KP_Enter:
-		fputs((sel && !(ev->state & ShiftMask)) ? sel->text : text, stdout);
+		fputs((sel && !(ev->state & ShiftMask)) ? sel->value : text, stdout);
 		fflush(stdout);
 		exit(EXIT_SUCCESS);
 	case XK_Right:
@@ -395,6 +396,12 @@
 			eprintf("cannot malloc %u bytes\n", sizeof *item);
 		if(!(item->text = strdup(buf)))
 			eprintf("cannot strdup %u bytes\n", strlen(buf)+1);
+		if(keysep && (item->value = strstr(item->text, keysep))) {
+			*item->value = '\0';
+			item->value += strlen(keysep);
+		}
+		else
+			item->value = item->text;
 		item->next = item->left = item->right = NULL;
 		inputw = MAX(inputw, textw(dc, item->text));
 	}
@@ -514,6 +521,8 @@
 			lines = atoi(argv[++i]);
 		else if(!strcmp(argv[i], "-p"))
 			prompt = argv[++i];
+		else if(!strcmp(argv[i], "-S"))
+			keysep = argv[++i];
 		else if(!strcmp(argv[i], "-fn"))
 			font = argv[++i];
 		else if(!strcmp(argv[i], "-nb"))
