Index: gnome-settings-daemon/gnome-settings-multimedia-keys.c
===================================================================
--- gnome-settings-daemon/gnome-settings-multimedia-keys.c	(revision 7408)
+++ gnome-settings-daemon/gnome-settings-multimedia-keys.c	(working copy)
@@ -86,16 +86,55 @@ acme_error (char * msg)
 		G_CALLBACK (gtk_widget_destroy), NULL);
 }
 
+static char *
+get_term_command(Acme *acme) {
+	gchar *cmd_term;
+	gchar *cmd_args;
+	gchar *cmd;
+
+	cmd_term = gconf_client_get_string (acme->conf_client,
+				   "/desktop/gnome/applications/terminal/exec", NULL);
+	if ((cmd_term == NULL) || (strcmp (cmd_term, "") == 0)) 
+		return NULL;
+	
+	cmd_args = gconf_client_get_string (acme->conf_client,
+					   "/desktop/gnome/applications/terminal/exec_arg", NULL);
+	if ((cmd_args != NULL) && (strcmp (cmd_term, "") != 0)) {
+		cmd = g_strdup_printf ("%s %s -e", cmd_term, cmd_args);
+		g_free(cmd_args);
+	} else
+		cmd = g_strdup_printf ("%s -e ", cmd_term);
+	g_free(cmd_term);
+
+	return cmd;
+}
+
 static void
-execute (char *cmd, gboolean sync)
+execute (Acme *acme, char *cmd, gboolean sync, gboolean need_term)
 {
 	gboolean retval;
 	gchar **argv;
 	gint argc;
+	char *exec;
+	char *term = NULL;
 
 	retval = FALSE;
 
-	if (g_shell_parse_argv (cmd, &argc, &argv, NULL)) {
+	if (need_term) {
+		term = get_term_command(acme);
+		if ((term == NULL) || (strcmp(term, "") == 0)) {
+			acme_error(_("Could not get default terminal."
+				   "Verify that your default terminal setting points to valid application."));
+			return;
+		}
+	}
+	if (term != NULL) {
+		exec = g_strdup_printf("%s%s", term, cmd);
+		g_free (exec);
+	} else
+		exec = g_strdup(cmd);
+
+	if (g_shell_parse_argv (exec, &argc, &argv, NULL)) {
 		if (sync != FALSE) {
 			retval = g_spawn_sync (g_get_home_dir (),
 			                       argv, NULL, G_SPAWN_SEARCH_PATH,
@@ -112,15 +151,15 @@ execute (char *cmd, gboolean sync)
 	if (retval == FALSE)
 	{
 		char *msg;
-
 		msg = g_strdup_printf
 			(_("Couldn't execute command: %s\n"
 			   "Verify that this command exists."),
-			 cmd);
+			 exec);
 
 		acme_error (msg);
 		g_free (msg);
 	}
+	g_free(exec);
 }
 
 static void
@@ -409,7 +448,7 @@ do_unknown_action (Acme *acme, const cha
 
 	command = g_strdup_printf (string, url);
 
-	execute (command, FALSE);
+	execute (acme, command, FALSE, FALSE);
 
 	g_free (command);
 	g_free (string);
@@ -424,7 +463,7 @@ do_help_action (Acme *acme)
 			"/desktop/gnome/url-handlers/ghelp/command",
 			NULL);
 
-	if (string == NULL && strcmp (string, "") == 0)
+	if (string == NULL || strcmp (string, "") == 0)
 	{
 		do_unknown_action (acme, "ghelp:");
 		return;
@@ -432,7 +471,7 @@ do_help_action (Acme *acme)
 
 	command = g_strdup_printf (string, "");
 
-	execute (command, FALSE);
+	execute (acme, command, FALSE, FALSE);
 
 	g_free (command);
 	g_free (string);
@@ -447,12 +486,14 @@ do_mail_action (Acme *acme)
 			"/desktop/gnome/url-handlers/mailto/command",
 			NULL);
 
+
 	if (string == NULL || strcmp (string, "") == 0)
 		return;
 
 	command = g_strdup_printf (string, "");
 
-	execute (command, FALSE);
+	execute (acme, command, FALSE, gconf_client_get_bool (acme->conf_client,
+					   "/desktop/gnome/url-handlers/mailto/needs_terminal", NULL));
 
 	g_free (command);
 	g_free (string);
@@ -462,10 +503,15 @@ static void
 do_media_action (Acme *acme)
 {
 	char *command;
+
 	command = gconf_client_get_string (acme->conf_client,
-					   GCONF_MISC_DIR "/eject_command", NULL);
-	if ((command != NULL) && (strcmp (command, "") != 0))
-		execute (command, FALSE);
+					   "/desktop/gnome/applications/media/exec", NULL);
+	if ((command == NULL) || (strcmp (command, "") == 0))
+		return;
+
+	execute (acme, command, FALSE, gconf_client_get_bool (acme->conf_client,
+					   "/desktop/gnome/applications/media/needs_term", NULL));
+
 	g_free (command);
 }
 
@@ -489,7 +535,8 @@ do_www_action (Acme *acme, const char *u
 	else
 		command = g_strdup_printf (string, url);
 
-	execute (command, FALSE);
+	execute (acme, command, FALSE, gconf_client_get_bool (acme->conf_client,
+					   "/desktop/gnome/url-handlers/http/needs_terminal", NULL));
 
 	g_free (command);
 	g_free (string);
@@ -498,7 +545,7 @@ do_www_action (Acme *acme, const char *u
 static void
 do_exit_action (Acme *acme)
 {
-	execute ("gnome-session-save --kill", FALSE);
+	execute (acme, "gnome-session-save --kill", FALSE, FALSE);
 }
 
 static void
@@ -514,9 +561,9 @@ do_eject_action (Acme *acme)
 	command = gconf_client_get_string (acme->conf_client,
 					   GCONF_MISC_DIR "/eject_command", NULL);
 	if ((command != NULL) && (strcmp (command, "") != 0))
-		execute (command, FALSE);
+		execute (acme, command, FALSE, FALSE);
 	else
-		execute ("eject", FALSE);
+		execute (acme, "eject", FALSE, FALSE);
 
 	g_free (command);
 }
@@ -602,10 +649,10 @@ do_action (Acme *acme, int type)
 		do_eject_action (acme);
 		break;
 	case HOME_KEY:
-		execute ("nautilus", FALSE);
+		execute (acme, "nautilus", FALSE, FALSE);
 		break;
 	case SEARCH_KEY:
-		execute ("gnome-search-tool", FALSE);
+		execute (acme, "gnome-search-tool", FALSE, FALSE);
 		break;
 	case EMAIL_KEY:
 		do_mail_action (acme);
@@ -615,9 +662,9 @@ do_action (Acme *acme, int type)
 		break;
 	case SCREENSAVER_KEY:
 		if ((cmd = g_find_program_in_path ("gnome-screensaver-command")))
-			execute ("gnome-screensaver-command --lock", FALSE);
+			execute (acme, "gnome-screensaver-command --lock", FALSE, FALSE);
 		else
-			execute ("xscreensaver-command -lock", FALSE);
+			execute (acme, "xscreensaver-command -lock", FALSE, FALSE);
 
 		g_free (cmd);
 		break;
