Index: moc/interface.c
===================================================================
--- moc.orig/interface.c	2009-09-08 00:17:26.000000000 +0200
+++ moc/interface.c	2009-09-08 00:18:18.000000000 +0200
@@ -2758,6 +2758,34 @@
 	}
 }
 
+static void randomize_playlist ()
+{
+	logit ("Randomizing playlist");
+
+	plist_shuffle (playlist);
+	send_int_to_srv (CMD_LOCK);
+
+	if (get_server_plist_serial() == plist_get_serial(playlist)) {
+		logit ("Sending randomized playlist to server");
+		send_playlist (playlist, 1);
+	}
+
+	if (options_get_int("SyncPlaylist")) {
+		send_int_to_srv (CMD_CLI_PLIST_CLEAR);
+		iface_set_status ("Notifying clients...");
+		send_items_to_clients (playlist);
+		iface_set_status ("");
+		plist_clear (playlist);
+
+		if (iface_in_plist_menu())
+			waiting_for_plist_load = 1;
+	}
+	else
+		iface_set_dir_content (IFACE_MENU_PLIST, playlist, NULL, NULL);
+
+	send_int_to_srv (CMD_UNLOCK);
+}
+
 /* Add themes found in the directory to the theme selection menu.
  * Return the number of items added. */
 static int add_themes_to_menu (const char *themes_dir)
@@ -3527,6 +3555,9 @@
 			case KEY_CMD_QUEUE_CLEAR:
 				cmd_clear_queue ();
 				break;
+			case KEY_CMD_PLIST_RANDOMIZE:
+				randomize_playlist();
+				break;
 			default:
 				abort ();
 		}
Index: moc/keymap.example
===================================================================
--- moc.orig/keymap.example	2009-09-08 00:17:23.000000000 +0200
+++ moc/keymap.example	2009-09-08 00:18:18.000000000 +0200
@@ -130,6 +130,7 @@
 playlist_full_paths =	P
 enqueue_file =		z
 clear_queue =		Z
+randomize_playlist =	O
 
 exec_command1 = 	F1
 exec_command2 = 	F2
Index: moc/keys.c
===================================================================
--- moc.orig/keys.c	2009-09-08 00:17:23.000000000 +0200
+++ moc/keys.c	2009-09-08 00:18:18.000000000 +0200
@@ -823,6 +823,14 @@
 		CON_MENU,
 		{ 'Z', -1 },
 		1
+	},
+	{
+		KEY_CMD_PLIST_RANDOMIZE,
+		"randomize_playlist",
+		"Randomize playlist",
+		CON_MENU,
+		{ 'O', -1 },
+		1
 	}
 };
 
Index: moc/keys.h
===================================================================
--- moc.orig/keys.h	2009-09-08 00:17:23.000000000 +0200
+++ moc/keys.h	2009-09-08 00:18:18.000000000 +0200
@@ -99,6 +99,7 @@
 	KEY_CMD_LYRICS,
 	KEY_CMD_QUEUE_TOGGLE_FILE,
 	KEY_CMD_QUEUE_CLEAR,
+	KEY_CMD_PLIST_RANDOMIZE,
 	KEY_CMD_WRONG
 };
 

