--- gdm-2.16.0/daemon/gdm.c.org	2006-09-20 11:57:54.000000000 +0100
+++ gdm-2.16.0/daemon/gdm.c	2006-10-02 11:28:57.000000000 +0100
@@ -714,6 +714,28 @@
 		   "gdm_child_action", strerror (errno));
 }
 
+/*Added by Lukas for windows thingy*/
+static void
+custom_cmd (void)
+{
+	char **argv;
+
+	gdm_info (_("Executing custom command..."));
+
+	gdm_final_cleanup ();
+	VE_IGNORE_EINTR (g_chdir ("/"));
+
+#ifdef __linux__
+	change_to_first_and_clear (TRUE);
+#endif /* __linux */
+
+	argv = ve_split (gdm_get_value_string (GDM_KEY_CUSTOM_CMD));
+	if (argv != NULL && argv[0] != NULL)
+		VE_IGNORE_EINTR (execv (argv[0], argv));
+
+	gdm_error (_("%s: Execution of custom command failed: %s"), 
+		   "gdm_child_action", strerror (errno));
+}
 
 static gboolean 
 gdm_cleanup_children (void)
@@ -815,18 +837,20 @@
     if ( ! sysmenu &&
 	(status == DISPLAY_RESTARTGDM ||
 	 status == DISPLAY_REBOOT ||
+	 status == DISPLAY_CUSTOM_CMD || //Added by Lukas
 	 status == DISPLAY_SUSPEND ||
 	 status == DISPLAY_HALT)) {
-	    gdm_info (_("Restart GDM, Restart machine, Suspend, or Halt request when there is no system menu from display %s"), d->name);
+	    gdm_info (_("Restart GDM, Restart machine, Execute custom cmd, Suspend, or Halt request when there is no system menu from display %s"), d->name);
 	    status = DISPLAY_REMANAGE;
     }
 
     if ( ! d->attached &&
 	(status == DISPLAY_RESTARTGDM ||
 	 status == DISPLAY_REBOOT ||
+	 status == DISPLAY_CUSTOM_CMD || //Added by Lukas
 	 status == DISPLAY_SUSPEND ||
 	 status == DISPLAY_HALT)) {
-	    gdm_info (_("Restart GDM, Restart machine, Suspend or Halt request from a non-static display %s"), d->name);
+	    gdm_info (_("Restart GDM, Restart machine, Execute custom cmd, Suspend or Halt request from a non-static display %s"), d->name);
 	    status = DISPLAY_REMANAGE;
     }
 
@@ -868,6 +892,10 @@
 	    if (gdm_get_value_string (GDM_KEY_REBOOT) == NULL)
 		    status = DISPLAY_REMANAGE;
 	    break;
+    case DISPLAY_CUSTOM_CMD://Added by Lukas
+	    if (gdm_get_value_string (GDM_KEY_CUSTOM_CMD) == NULL)
+		    status = DISPLAY_REMANAGE;
+	    break;
     case DISPLAY_HALT:
 	    if (gdm_get_value_string (GDM_KEY_HALT) == NULL)
 		    status = DISPLAY_REMANAGE;
@@ -911,6 +939,13 @@
 	goto start_autopsy;
 	break;
 	
+    case DISPLAY_CUSTOM_CMD:       /* Restart machine to windows - added by Lukas*/	
+	custom_cmd ();
+
+	status = DISPLAY_REMANAGE;
+	goto start_autopsy;
+	break;
+
     case DISPLAY_HALT:		/* Halt machine */
 	halt_machine ();
 
@@ -1081,6 +1116,10 @@
 		restart_machine ();
 		break;
 
+	case GDM_LOGOUT_ACTION_CUSTOM_CMD://added by Lukas
+	       custom_cmd ();
+		break;
+
 	case GDM_LOGOUT_ACTION_SUSPEND:
 		suspend_machine ();
 		break;
@@ -3275,6 +3314,13 @@
 			sep = ";";
 		}
 		if (sysmenu && disp->attached &&
+		    ! ve_string_empty (gdm_get_value_string (GDM_KEY_CUSTOM_CMD))) {//Added by Lukas
+			g_string_append_printf (msg, "%s%s", sep, GDM_SUP_LOGOUT_ACTION_CUSTOM_CMD);
+			if (logout_action == GDM_LOGOUT_ACTION_CUSTOM_CMD)
+				g_string_append (msg, "!");
+			sep = ";";
+		}
+		if (sysmenu && disp->attached &&
 		    ! ve_string_empty (gdm_get_value_string (GDM_KEY_SUSPEND))) {
 			g_string_append_printf (msg, "%s%s", sep, GDM_SUP_LOGOUT_ACTION_SUSPEND);
 			if (logout_action == GDM_LOGOUT_ACTION_SUSPEND)
@@ -3323,6 +3369,13 @@
 					GDM_LOGOUT_ACTION_REBOOT;
 				was_ok = TRUE;
 			}
+		} else if (strcmp (action, GDM_SUP_LOGOUT_ACTION_CUSTOM_CMD) == 0) {//added by Lukas
+			if (sysmenu && disp->attached &&
+			    ! ve_string_empty (gdm_get_value_string (GDM_KEY_CUSTOM_CMD))) {
+				disp->logout_action =
+					GDM_LOGOUT_ACTION_CUSTOM_CMD;
+				was_ok = TRUE;
+			}
 		} else if (strcmp (action, GDM_SUP_LOGOUT_ACTION_SUSPEND) == 0) {
 			if (sysmenu && disp->attached &&
 			    ! ve_string_empty (gdm_get_value_string (GDM_KEY_SUSPEND))) {
@@ -3376,6 +3429,13 @@
 					GDM_LOGOUT_ACTION_REBOOT;
 				was_ok = TRUE;
 			}
+		} else if (strcmp (action, GDM_SUP_LOGOUT_ACTION_CUSTOM_CMD) == 0) {//added by Lukas
+		       if (sysmenu && disp->attached &&
+			    ! ve_string_empty (gdm_get_value_string (GDM_KEY_CUSTOM_CMD))) {
+				safe_logout_action =
+					GDM_LOGOUT_ACTION_CUSTOM_CMD;
+				was_ok = TRUE;
+			}
 		} else if (strcmp (action, GDM_SUP_LOGOUT_ACTION_SUSPEND) == 0) {
 			if (sysmenu && disp->attached &&
 			    ! ve_string_empty (gdm_get_value_string (GDM_KEY_SUSPEND))) {
--- gdm-2.16.0/daemon/gdmconfig.c.org	2006-09-20 16:42:36.000000000 +0100
+++ gdm-2.16.0/daemon/gdmconfig.c	2006-10-02 11:30:20.000000000 +0100
@@ -115,6 +115,11 @@
 static gchar *GdmXKeepsCrashing = NULL;
 static gchar *GdmHalt = NULL;
 static gchar *GdmReboot = NULL;
+static gchar *GdmCustomCmd = NULL;//Added Lukas
+static gchar *GdmCustomCmdLabel = NULL;
+static gchar *GdmCustomCmdLRLabel = NULL;
+static gchar *GdmCustomCmdText = NULL;
+static gchar *GdmCustomCmdTooltip = NULL;
 static gchar *GdmSuspend = NULL;
 static gchar *GdmServAuthDir = NULL;
 static gchar *GdmMulticastAddr;
@@ -438,6 +443,11 @@
    gdm_config_add_hash (GDM_KEY_AUTOMATIC_LOGIN, &GdmAutomaticLogin, &string_type);
    gdm_config_add_hash (GDM_KEY_GTK_MODULES_LIST, &GdmGtkModulesList, &string_type);
    gdm_config_add_hash (GDM_KEY_REBOOT, &GdmReboot, &string_type);
+   gdm_config_add_hash (GDM_KEY_CUSTOM_CMD, &GdmCustomCmd, &string_type);//Added Lukas
+   gdm_config_add_hash (GDM_KEY_CUSTOM_CMD_LABEL, &GdmCustomCmdLabel, &string_type);
+   gdm_config_add_hash (GDM_KEY_CUSTOM_CMD_LR_LABEL, &GdmCustomCmdLRLabel, &string_type);
+   gdm_config_add_hash (GDM_KEY_CUSTOM_CMD_TEXT, &GdmCustomCmdText, &string_type);
+   gdm_config_add_hash (GDM_KEY_CUSTOM_CMD_TOOLTIP, &GdmCustomCmdTooltip, &string_type);
    gdm_config_add_hash (GDM_KEY_HALT, &GdmHalt, &string_type);
    gdm_config_add_hash (GDM_KEY_SUSPEND, &GdmSuspend, &string_type);
    gdm_config_add_hash (GDM_KEY_LOG_DIR, &GdmLogDir, &string_type);
@@ -1076,9 +1086,10 @@
                                        "gdm", "Xsession", NULL);
        }
 
-   /* Halt, Reboot, and Suspend commands */
+   /* Halt, Reboot, Custom and Suspend commands */
    } else if (is_key (key, GDM_KEY_HALT) ||
               is_key (key, GDM_KEY_REBOOT) ||
+	      is_key (key, GDM_KEY_CUSTOM_CMD) ||//Added Lukas
               is_key (key, GDM_KEY_SUSPEND)) {
        if (value != NULL)
           *setting = ve_get_first_working_command (value, FALSE);
--- gdm-2.16.0/daemon/gdm.h.org	2006-09-20 11:58:04.000000000 +0100
+++ gdm-2.16.0/daemon/gdm.h	2006-10-02 11:25:27.000000000 +0100
@@ -71,6 +71,7 @@
 #define DISPLAY_SUSPEND 17	/* Suspend (don't use, use the interrupt) */
 #define DISPLAY_CHOSEN 20	/* successful chooser session,
 				   restart display */
+#define DISPLAY_CUSTOM_CMD 21   /* User-defined custom command */
 #define DISPLAY_RUN_CHOOSER 30	/* Run chooser */
 #define DISPLAY_XFAILED 64	/* X failed */
 #define DISPLAY_GREETERFAILED 65 /* greeter failed (crashed) */
@@ -234,6 +235,19 @@
 #define GDM_KEY_FAILSAFE_XSERVER "daemon/FailsafeXServer="
 #define GDM_KEY_X_KEEPS_CRASHING "daemon/XKeepsCrashing=" GDMCONFDIR "/XKeepsCrashing"
 #define GDM_KEY_REBOOT  "daemon/RebootCommand=" REBOOT_COMMAND
+/* The five options below are used for specifying User-defined custom command option
+   GDM_KEY_CUSTOM_CMD - The actual command(s) that will be run if pressed/selected
+   GDM_KEY_CUSTOM_CMD_LABEL - The stock label that will be displayed on the menus and buttons
+   GDM_KEY_CUSTOM_CMD_LR_LABEL - The stock label that will be displayed on the lists and radio buttons
+   GDM_KEY_CUSTOM_CMD_TEXT - The text that will appear in the Yes/No dialog boxes when execuuted      
+   GDM_KEY_CUSTOM_CMD_TOOLTIP - The text that will be displayed as tooltip
+ */
+#define GDM_KEY_CUSTOM_CMD "daemon/CustomCommand=" CUSTOM_COMMAND //Added by Lukas
+#define GDM_KEY_CUSTOM_CMD_LABEL "daemon/CustomCommandLabel=" CUSTOM_COMMAND_LABEL
+#define GDM_KEY_CUSTOM_CMD_LR_LABEL "daemon/CustomCommandLRLabel=" CUSTOM_COMMAND_LR_LABEL
+#define GDM_KEY_CUSTOM_CMD_TEXT "daemon/CustomCommandText=" CUSTOM_COMMAND_TEXT
+#define GDM_KEY_CUSTOM_CMD_TOOLTIP "daemon/CustomCommandTooltip=" CUSTOM_COMMAND_TOOLTIP
+
 #define GDM_KEY_ROOT_PATH "daemon/RootPath=/sbin:/usr/sbin:" GDM_USER_PATH
 #define GDM_KEY_SERV_AUTHDIR "daemon/ServAuthDir=" AUTHDIR
 #define GDM_KEY_SESSION_DESKTOP_DIR "daemon/SessionDesktopDir=/etc/X11/sessions/:" DMCONFDIR "/Sessions/:" DATADIR "/gdm/BuiltInSessions/:" DATADIR "/xsessions/"
@@ -437,6 +451,7 @@
 	GDM_LOGOUT_ACTION_NONE = 0,
 	GDM_LOGOUT_ACTION_HALT,
 	GDM_LOGOUT_ACTION_REBOOT,
+	GDM_LOGOUT_ACTION_CUSTOM_CMD,//Added by Lukas
 	GDM_LOGOUT_ACTION_SUSPEND,
 	GDM_LOGOUT_ACTION_LAST
 } GdmLogoutAction;
@@ -1199,6 +1214,7 @@
 #define GDM_SUP_LOGOUT_ACTION_NONE	"NONE"
 #define GDM_SUP_LOGOUT_ACTION_HALT	"HALT"
 #define GDM_SUP_LOGOUT_ACTION_REBOOT	"REBOOT"
+#define GDM_SUP_LOGOUT_ACTION_CUSTOM_CMD "CUSTOM_CMD"//Added by Lukas
 #define GDM_SUP_LOGOUT_ACTION_SUSPEND	"SUSPEND"
 /*
  */
--- gdm-2.16.0/daemon/slave.c.org	2006-09-20 11:58:40.000000000 +0100
+++ gdm-2.16.0/daemon/slave.c	2006-09-29 14:40:09.000000000 +0100
@@ -4715,6 +4715,7 @@
 		if (WIFEXITED (status) &&
 		    (WEXITSTATUS (status) == DISPLAY_ABORT ||
 		     WEXITSTATUS (status) == DISPLAY_REBOOT ||
+		     WEXITSTATUS (status) == DISPLAY_CUSTOM_CMD || //added by Lukas
 		     WEXITSTATUS (status) == DISPLAY_HALT ||
 		     WEXITSTATUS (status) == DISPLAY_SUSPEND ||
 		     WEXITSTATUS (status) == DISPLAY_RUN_CHOOSER ||
--- gdm-2.16.0/gui/gdmlogin.c.org	2006-09-20 11:59:49.000000000 +0100
+++ gdm-2.16.0/gui/gdmlogin.c	2006-10-02 12:42:02.000000000 +0100
@@ -670,6 +670,20 @@
 	}
 }
 
+/*Lukas modified for windows thingy*/
+static void
+gdm_custom_cmd_handler (void)
+{
+	if (gdm_wm_warn_dialog (
+	    ((ve_string_empty (gdm_config_get_string (GDM_KEY_CUSTOM_CMD_TEXT))) ? _("Are you sure?") : gdm_config_get_string (GDM_KEY_CUSTOM_CMD_TEXT)) , "",
+	    _("_OK"), NULL, TRUE) == GTK_RESPONSE_YES) {
+	
+		closelog ();
+
+		gdm_kill_thingies ();
+		_exit (DISPLAY_CUSTOM_CMD);
+	}
+}
 
 static void
 gdm_login_halt_handler (void)
@@ -2390,6 +2404,16 @@
 		got_anything = TRUE;
 	}
 	
+	if (gdm_working_command_exists (gdm_config_get_string (GDM_KEY_CUSTOM_CMD))) {//added by Lukas for windows thingy
+		item = gtk_menu_item_new_with_mnemonic (((ve_string_empty (gdm_config_get_string (GDM_KEY_CUSTOM_CMD_LABEL))) ? _("_Custom") : gdm_config_get_string (GDM_KEY_CUSTOM_CMD_LABEL)));
+		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+		g_signal_connect (G_OBJECT (item), "activate",
+				  G_CALLBACK (gdm_custom_cmd_handler), 
+				  NULL);
+		gtk_widget_show (GTK_WIDGET (item));
+		got_anything = TRUE;
+	}
+
 	if (gdm_working_command_exists (gdm_config_get_string (GDM_KEY_HALT))) {
 		item = gtk_menu_item_new_with_mnemonic (_("Shut _Down"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
@@ -2978,6 +3002,11 @@
         gdm_config_get_string (GDM_KEY_LOCALE_FILE);
 	gdm_config_get_string (GDM_KEY_LOGO);
         gdm_config_get_string (GDM_KEY_REBOOT);
+	gdm_config_get_string (GDM_KEY_CUSTOM_CMD);//Added by Lukas
+	gdm_config_get_string (GDM_KEY_CUSTOM_CMD_LABEL);
+	gdm_config_get_string (GDM_KEY_CUSTOM_CMD_LR_LABEL);
+	gdm_config_get_string (GDM_KEY_CUSTOM_CMD_TEXT);
+	gdm_config_get_string (GDM_KEY_CUSTOM_CMD_TOOLTIP);
         gdm_config_get_string (GDM_KEY_REMOTE_WELCOME);
 	gdm_config_get_string (GDM_KEY_SESSION_DESKTOP_DIR);
 	gdm_config_get_string (GDM_KEY_SOUND_PROGRAM);
@@ -3071,6 +3100,11 @@
 	    gdm_config_reload_string (GDM_KEY_INFO_MSG_FONT) ||
 	    gdm_config_reload_string (GDM_KEY_LOCALE_FILE) ||
 	    gdm_config_reload_string (GDM_KEY_REBOOT) ||
+	    gdm_config_reload_string (GDM_KEY_CUSTOM_CMD) || //Added by Lukas
+	    gdm_config_reload_string (GDM_KEY_CUSTOM_CMD_TEXT) ||
+	    gdm_config_reload_string (GDM_KEY_CUSTOM_CMD_LABEL) ||
+	    gdm_config_reload_string (GDM_KEY_CUSTOM_CMD_LR_LABEL) ||
+	    gdm_config_reload_string (GDM_KEY_CUSTOM_CMD_TOOLTIP) ||
 	    gdm_config_reload_string (GDM_KEY_SESSION_DESKTOP_DIR) ||
 	    gdm_config_reload_string (GDM_KEY_SUSPEND) ||
 	    gdm_config_reload_string (GDM_KEY_TIMED_LOGIN) ||
--- gdm-2.16.0/gui/greeter/greeter.c.org	2006-09-20 12:00:12.000000000 +0100
+++ gdm-2.16.0/gui/greeter/greeter.c	2006-10-02 12:15:21.000000000 +0100
@@ -70,9 +70,19 @@
 static gboolean ignore_buttons = FALSE;
 gboolean GdmHaltFound          = FALSE;
 gboolean GdmRebootFound        = FALSE;
+gboolean GdmCustomCmdFound     = FALSE;//added by Lukas
+gboolean GdmCustomCmdTextFound = FALSE;
+gboolean GdmCustomCmdLabelFound = FALSE;
+gboolean GdmCustomCmdLRLabelFound = FALSE;
+gboolean GdmCustomCmdTooltipFound = FALSE;
 gboolean GdmSuspendFound       = FALSE;
 gboolean GdmConfiguratorFound  = FALSE;
 
+gchar *GdmCustomCmdLabel = NULL;
+gchar *GdmCustomCmdLRLabel = NULL;
+gchar *GdmCustomCmdText = NULL;
+gchar *GdmCustomCmdTooltip = NULL;
+
 /* FIXME: hack */
 GreeterItemInfo *welcome_string_info = NULL;
 
@@ -729,6 +739,11 @@
 	gdm_config_get_string (GDM_KEY_LOCALE_FILE);
 	gdm_config_get_string (GDM_KEY_HALT);
 	gdm_config_get_string (GDM_KEY_REBOOT);
+	gdm_config_get_string (GDM_KEY_CUSTOM_CMD);//added by Lukas
+	gdm_config_get_string (GDM_KEY_CUSTOM_CMD_TEXT);
+	gdm_config_get_string (GDM_KEY_CUSTOM_CMD_LABEL);
+	gdm_config_get_string (GDM_KEY_CUSTOM_CMD_LR_LABEL);
+	gdm_config_get_string (GDM_KEY_CUSTOM_CMD_TOOLTIP);
 	gdm_config_get_string (GDM_KEY_SUSPEND);
 	gdm_config_get_string (GDM_KEY_CONFIGURATOR);
 	gdm_config_get_string (GDM_KEY_INFO_MSG_FILE);
@@ -797,6 +812,11 @@
 	    gdm_config_reload_string (GDM_KEY_LOCALE_FILE) ||
 	    gdm_config_reload_string (GDM_KEY_HALT) ||
 	    gdm_config_reload_string (GDM_KEY_REBOOT) ||
+	    gdm_config_reload_string (GDM_KEY_CUSTOM_CMD) || //added by Lukas
+	    gdm_config_reload_string (GDM_KEY_CUSTOM_CMD_TEXT) ||
+	    gdm_config_reload_string (GDM_KEY_CUSTOM_CMD_LABEL) ||
+	    gdm_config_reload_string (GDM_KEY_CUSTOM_CMD_LR_LABEL) ||
+	    gdm_config_reload_string (GDM_KEY_CUSTOM_CMD_TOOLTIP) ||
 	    gdm_config_reload_string (GDM_KEY_SUSPEND) ||
 	    gdm_config_reload_string (GDM_KEY_CONFIGURATOR) ||
 	    gdm_config_reload_string (GDM_KEY_INFO_MSG_FILE) ||
@@ -1141,9 +1161,25 @@
   gdm_timed_delay      = gdm_config_get_int (GDM_KEY_TIMED_LOGIN_DELAY);
   GdmHaltFound         = gdm_working_command_exists (gdm_config_get_string (GDM_KEY_HALT));
   GdmRebootFound       = gdm_working_command_exists (gdm_config_get_string (GDM_KEY_REBOOT));
+  GdmCustomCmdFound    = gdm_working_command_exists (gdm_config_get_string (GDM_KEY_CUSTOM_CMD));//Added by Lukas
+  GdmCustomCmdTextFound    = !ve_string_empty (gdm_config_get_string (GDM_KEY_CUSTOM_CMD_TEXT));
+  GdmCustomCmdLabelFound   = !ve_string_empty (gdm_config_get_string (GDM_KEY_CUSTOM_CMD_LABEL));
+  GdmCustomCmdLRLabelFound   = !ve_string_empty (gdm_config_get_string (GDM_KEY_CUSTOM_CMD_LR_LABEL));
+  GdmCustomCmdTooltipFound   = !ve_string_empty (gdm_config_get_string (GDM_KEY_CUSTOM_CMD_TOOLTIP));
   GdmSuspendFound      = gdm_working_command_exists (gdm_config_get_string (GDM_KEY_SUSPEND));
   GdmConfiguratorFound = gdm_working_command_exists (gdm_config_get_string (GDM_KEY_CONFIGURATOR));
 
+  if(GdmCustomCmdLabelFound)
+      GdmCustomCmdLabel = gdm_config_get_string (GDM_KEY_CUSTOM_CMD_LABEL);
+
+  if(GdmCustomCmdLRLabelFound)
+      GdmCustomCmdLRLabel = gdm_config_get_string (GDM_KEY_CUSTOM_CMD_LR_LABEL);
+  
+  if(GdmCustomCmdTextFound)
+      GdmCustomCmdText = gdm_config_get_string (GDM_KEY_CUSTOM_CMD_TEXT);
+
+  if(GdmCustomCmdTooltipFound)
+      GdmCustomCmdTooltip = gdm_config_get_string (GDM_KEY_CUSTOM_CMD_TOOLTIP);
 
   if (g_getenv ("GDM_THEME") != NULL)
      gdm_graphical_theme = g_strdup (g_getenv ("GDM_THEME"));
--- gdm-2.16.0/gui/greeter/greeter_parser.c.org	2006-09-20 12:00:41.000000000 +0100
+++ gdm-2.16.0/gui/greeter/greeter_parser.c	2006-09-29 17:28:14.000000000 +0100
@@ -355,6 +355,11 @@
 	  g_free (*translated_text);
 	  *translated_text = g_strdup (_("_Restart"));
 	}
+      else if (g_ascii_strcasecmp ((char *) prop, "custom_cmd") == 0)//This else if has been added by Lukas 23.08.05
+        {
+	  g_free (*translated_text);	  
+	  *translated_text = g_strdup (((GdmCustomCmdLabelFound == TRUE) ? GdmCustomCmdLabel : _("_Custom")));
+	}
       else if (g_ascii_strcasecmp ((char *) prop, "chooser") == 0)
         {
 	  g_free (*translated_text);
--- gdm-2.16.0/gui/greeter/greeter_item.c.org	2006-09-20 14:14:32.000000000 +0100
+++ gdm-2.16.0/gui/greeter/greeter_item.c	2006-10-02 11:40:20.000000000 +0100
@@ -35,6 +35,11 @@
 
 extern gboolean GdmHaltFound;
 extern gboolean GdmRebootFound;
+extern gboolean GdmCustomCmdFound;//Added by Lukas
+extern gboolean GdmCustomCmdTextFound;
+extern gboolean GdmCustomCmdLabelFound;
+extern gboolean GdmCustomCmdLRLabelFound;
+extern gboolean GdmCustomCmdTooltipFound;
 extern gboolean GdmSuspendFound;
 extern gboolean GdmConfiguratorFound;
 
@@ -204,6 +209,10 @@
       (info->show_type != NULL &&
        strcmp (info->show_type, "reboot") == 0))
 	  return FALSE;
+  if (( ! sysmenu || ! GdmCustomCmdFound) && //Added by Lukas
+      (info->show_type != NULL &&
+       strcmp (info->show_type, "custom_cmd") == 0))
+	  return FALSE;
   if (( ! sysmenu || ! GdmSuspendFound) &&
       (info->show_type != NULL &&
        strcmp (info->show_type, "suspend") == 0))
--- gdm-2.16.0/gui/greeter/greeter.dtd.org	2006-09-20 14:57:32.000000000 +0100
+++ gdm-2.16.0/gui/greeter/greeter.dtd	2006-09-29 15:49:56.000000000 +0100
@@ -19,7 +19,7 @@
 <!-- additional elements-->
 <!ELEMENT border EMPTY>
 
-<!-- internal id's are one of (user-pw-entry | caps-lock-warning | clock | pam-error | pam-message | pam-prompt | pam-warning | timed-label | language_button | disconnect_button | reboot_button | halt_button | session_button | suspend_button | system_button | config_button | chooser_button | userlist)
+<!-- internal id's are one of (user-pw-entry | caps-lock-warning | clock | pam-error | pam-message | pam-prompt | pam-warning | timed-label | language_button | disconnect_button | reboot_button | custom_cmd_button | halt_button | session_button | suspend_button | system_button | config_button | chooser_button | userlist)
      but there can be other id's -->
 <!ATTLIST item
 	type (rect | entry | pixmap | label | svg | rect | list) #REQUIRED
--- gdm-2.16.0/gui/greeter/greeter_system.c.org	2006-09-20 12:00:52.000000000 +0100
+++ gdm-2.16.0/gui/greeter/greeter_system.c	2006-10-02 12:41:40.000000000 +0100
@@ -39,6 +39,15 @@
 GtkWidget *dialog;
 extern gboolean GdmHaltFound;
 extern gboolean GdmRebootFound;
+extern gboolean GdmCustomCmdFound;//Added by Lukas
+extern gboolean GdmCustomCmdTextFound;
+extern gboolean GdmCustomCmdLabelFound;
+extern gboolean GdmCustomCmdLRLabelFound;
+extern gboolean GdmCustomCmdTooltipFound;
+extern gchar *GdmCustomCmdLabel;
+extern gchar *GdmCustomCmdLRLabel;
+extern gchar *GdmCustomCmdTooltip;
+extern gchar *GdmCustomCmdText;
 extern gboolean GdmSuspendFound;
 extern gboolean GdmConfiguratorFound;
 
@@ -78,6 +87,18 @@
 	}
 }
 
+/*This has been modified by Lukas*/
+static void
+query_greeter_custom_cmd_handler (void)
+{
+        if (gdm_wm_warn_dialog (((GdmCustomCmdTextFound == TRUE) ? GdmCustomCmdText : _("Are you sure?")), "",
+				_("_OK"), NULL, TRUE) == GTK_RESPONSE_YES) {
+		closelog ();
+		
+		_exit (DISPLAY_CUSTOM_CMD);
+	}
+}
+
 static void
 query_greeter_halt_handler (void)
 {
@@ -107,6 +128,13 @@
 	_exit (DISPLAY_REBOOT);
 }
 
+/*Added by Lukas for win thingy*/
+static void
+greeter_custom_cmd_handler (void)
+{
+	closelog ();
+	_exit (DISPLAY_CUSTOM_CMD);
+}
 
 static void
 greeter_halt_handler (void)
@@ -174,7 +202,7 @@
 				  NULL);
 	}
 
-	if (GdmRebootFound || GdmHaltFound || GdmSuspendFound) {
+	if (GdmRebootFound || GdmHaltFound || GdmSuspendFound || GdmCustomCmdFound) {//Added by Lukas
 		sep = gtk_separator_menu_item_new ();
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), sep);
 		gtk_widget_show (sep);
@@ -189,6 +217,15 @@
 				  NULL);
 	}
 
+	if (GdmCustomCmdFound) {//added by Lukas
+	        w = gtk_menu_item_new_with_mnemonic (((GdmCustomCmdLabelFound == TRUE) ? GdmCustomCmdLabel : _("_Custom")));
+		gtk_menu_shell_append (GTK_MENU_SHELL (menu), w);
+		gtk_widget_show (GTK_WIDGET (w));
+		g_signal_connect (G_OBJECT (w), "activate",
+				  G_CALLBACK (query_greeter_custom_cmd_handler),
+				  NULL);
+	}
+
 	if (GdmHaltFound) {
 		w = gtk_menu_item_new_with_mnemonic (_("Shut _Down"));
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), w);
@@ -232,6 +269,7 @@
   GtkWidget *halt_radio = NULL;
   GtkWidget *suspend_radio = NULL;
   GtkWidget *restart_radio = NULL;
+  GtkWidget *custom_cmd_radio = NULL;//added by Lukas
   GtkWidget *config_radio = NULL;
   GtkWidget *chooser_radio = NULL;
   gchar *s;
@@ -316,6 +354,23 @@
 	  gtk_widget_show (restart_radio);
   }
 
+  if (GdmCustomCmdFound) {//added by Lukas
+	  if (group_radio != NULL)
+		  radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (group_radio));
+	  custom_cmd_radio = gtk_radio_button_new_with_mnemonic (radio_group,
+							     ((GdmCustomCmdLRLabelFound == TRUE) ? GdmCustomCmdLRLabel : _("_Execute custom command")));
+	  group_radio = custom_cmd_radio;
+	  gtk_tooltips_set_tip (tooltips, GTK_WIDGET (custom_cmd_radio),
+				((GdmCustomCmdTooltipFound == TRUE) ? GdmCustomCmdTooltip : _("Execute custom command")),
+				NULL);
+	  g_signal_connect (G_OBJECT(custom_cmd_radio), "button_press_event",
+			    G_CALLBACK(radio_button_press_event), NULL);
+	  gtk_box_pack_start (GTK_BOX (vbox),
+			      custom_cmd_radio,
+			      FALSE, FALSE, 4);
+	  gtk_widget_show (custom_cmd_radio);
+  }
+
   if (GdmSuspendFound) {
 	  if (group_radio != NULL)
 		  radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (group_radio));
@@ -399,6 +454,8 @@
     greeter_halt_handler ();
   else if (restart_radio != NULL && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (restart_radio)))
     greeter_restart_handler ();
+  else if (custom_cmd_radio != NULL && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (custom_cmd_radio)))//added by Lukas
+    greeter_custom_cmd_handler ();
   else if (suspend_radio != NULL && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (suspend_radio)))
     greeter_suspend_handler ();
   else if (config_radio != NULL && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (config_radio)))
@@ -416,6 +473,9 @@
   greeter_item_register_action_callback ("reboot_button",
 					 (ActionFunc)query_greeter_restart_handler,
 					 NULL);
+  greeter_item_register_action_callback ("custom_cmd_button",//added by Lukas
+					 (ActionFunc)query_greeter_custom_cmd_handler,
+					 NULL);
   greeter_item_register_action_callback ("halt_button",
 					 (ActionFunc)query_greeter_halt_handler,
 					 NULL);
--- gdm-2.16.0/gui/greeter/greeter_configuration.h.org	2006-09-20 12:00:25.000000000 +0100
+++ gdm-2.16.0/gui/greeter/greeter_configuration.h	2006-10-02 11:36:22.000000000 +0100
@@ -29,10 +29,20 @@
 extern gboolean GdmChooserButton;
 extern gchar *GdmHalt;
 extern gchar *GdmReboot;
+extern gchar *GdmCustomCmd;//added by Lukas
+extern gchar *GdmCustomCmdText;
+extern gchar *GdmCustomCmdLabel;
+extern gchar *GdmCustomCmdLRLabel;
+extern gchar *GdmCustomCmdTooltip;
 extern gchar *GdmSuspend;
 extern gchar *GdmConfigurator;
 extern gboolean GdmHaltFound;
 extern gboolean GdmRebootFound;
+extern gboolean GdmCustomCmdFound;//added by Lukas
+extern gboolean GdmCustomCmdTextFound;
+extern gboolean GdmCustomCmdLabelFound;
+extern gboolean GdmCustomCmdLRLabelFound;
+extern gboolean GdmCustomCmdTooltipFound;
 extern gboolean GdmSuspendFound;
 extern gboolean GdmConfiguratorFound;
 extern gchar *GdmSessionDir;
--- gdm-2.16.0/acconfig.h.org	2006-09-20 11:55:30.000000000 +0100
+++ gdm-2.16.0/acconfig.h	2006-10-02 11:48:06.000000000 +0100
@@ -3,6 +3,11 @@
 #undef GETTEXT_PACKAGE
 #undef HALT_COMMAND
 #undef REBOOT_COMMAND
+#undef CUSTOM_COMMAND
+#undef CUSTOM_COMMAND_TEXT
+#undef CUSTOM_COMMAND_LR_LABEL
+#undef CUSTOM_COMMAND_LABEL
+#undef CUSTOM_COMMAND_TOOLTIP
 #undef SOUND_PROGRAM
 #undef SUSPEND_COMMAND
 #undef ENABLE_IPV6
--- gdm-2.16.0/configure.ac.org	2006-09-20 12:59:52.000000000 +0100
+++ gdm-2.16.0/configure.ac	2006-10-02 11:55:54.000000000 +0100
@@ -1082,6 +1082,16 @@
 AC_DEFINE_UNQUOTED(HALT_COMMAND,"$HALT_COMMAND")
 AC_SUBST(REBOOT_COMMAND)
 AC_DEFINE_UNQUOTED(REBOOT_COMMAND,"$REBOOT_COMMAND")
+AC_SUBST(CUSTOM_COMMAND)
+AC_DEFINE_UNQUOTED(CUSTOM_COMMAND,"$CUSTOM_COMMAND")
+AC_SUBST(CUSTOM_COMMAND_TEXT)
+AC_DEFINE_UNQUOTED(CUSTOM_COMMAND_TEXT,"$CUSTOM_COMMAND_TEXT")
+AC_SUBST(CUSTOM_COMMAND_LR_LABEL)
+AC_DEFINE_UNQUOTED(CUSTOM_COMMAND_LR_LABEL,"$CUSTOM_COMMAND_LR_LABEL")
+AC_SUBST(CUSTOM_COMMAND_LABEL)
+AC_DEFINE_UNQUOTED(CUSTOM_COMMAND_LABEL,"$CUSTOM_COMMAND_LABEL")
+AC_SUBST(CUSTOM_COMMAND_TOOLTIP)
+AC_DEFINE_UNQUOTED(CUSTOM_COMMAND_TOOLTIP,"$CUSTOM_COMMAND_TOOLTIP")
 AC_SUBST(SUSPEND_COMMAND)
 AC_DEFINE_UNQUOTED(SUSPEND_COMMAND,"$SUSPEND_COMMAND")
 AC_SUBST(XSESSION_SHELL)
--- gdm-2.16.0/docs/C/gdm.xml.org	2006-10-02 14:45:14.000000000 +0100
+++ gdm-2.16.0/docs/C/gdm.xml	2006-10-02 16:52:54.000000000 +0100
@@ -170,7 +170,7 @@
         (ServAuthDir, PidFile, etc.), system applications (SoundProgram), etc.
         Some configuration values depend on OS interfaces may need to be
         modified to work on a given OS.  Typical examples are HaltCommand,
-        RebootCommand, SuspendCommand, StandardXServer, Xnest, SoundProgram,
+        RebootCommand, CustomCommand,SuspendCommand, StandardXServer, Xnest, SoundProgram,
         and the &quot;command&quot; value for each &quot;server-foo&quot;.
       </para>
 
@@ -1856,6 +1856,70 @@
           </varlistentry>
           
           <varlistentry>
+            <term>CustomCommand</term>
+            <listitem>
+              <synopsis>CustomCommand=</synopsis>
+              <para>
+                Full path and arguments to command to be executed when user
+                selects &quot;Custom Command&quot; from the Actions menu.  This can
+                be a ';' separated list of commands to try.  If a value is
+                missing, the custom command is not available.  By 
+                default this value is not enabled, so to enable 
+                &quot;Custom Command&quot; it must be
+                set to a nonempty value.
+              </para>
+            </listitem>
+          </varlistentry>
+          
+          <varlistentry>
+            <term>CustomCommandLabel</term>
+            <listitem>
+              <synopsis>CustomCommandLabel=</synopsis>
+              <para>
+                Specifies the stock label that will be displayed on the &quot;Custom Command&quot;
+                buttons and menu items. If not specified the default value is  &quot;_Custom&quot;. This 
+                option is only valid if <filename>CustomCommand</filename> is defined.
+              </para>
+            </listitem>
+          </varlistentry>
+          
+          <varlistentry>
+            <term>CustomCommandLRLabel</term>
+            <listitem>
+              <synopsis>CustomCommandLRLabel=</synopsis>
+              <para>
+                Specifies the stock label that will be displayed on the &quot;Custom Command&quot;
+                list items and radio buttons. If not specified the default value is  &quot;_Execute custom command&quot;. This 
+                option is only valid if <filename>CustomCommand</filename> is defined.
+              </para>
+            </listitem>
+          </varlistentry>
+          
+          <varlistentry>
+            <term>CustomCommandText</term>
+            <listitem>
+              <synopsis>CustomCommandText=</synopsis>
+              <para>
+                Specifies the message that will be displayed on the warning dialog box once &quot;Custom Command&quot;
+                button/menu item/radio button/list item has been activated. If not specified the default value is  &quot;Are you sure?&quot;. 
+                This option is only valid if <filename>CustomCommand</filename> is defined.
+              </para>
+            </listitem>
+          </varlistentry>
+          
+          <varlistentry>
+            <term>CustomCommandTooltip</term>
+            <listitem>
+              <synopsis>CustomCommandTooltip=</synopsis>
+              <para>
+                Specifies the message that will be displayed on tooltips for &quot;Custom Command&quot;
+                entries. If not specified the default value is  &quot;Execute custom command&quot;. This 
+                option is only valid if <filename>CustomCommand</filename> is defined.
+              </para>
+            </listitem>
+          </varlistentry>
+          
+          <varlistentry>
             <term>DefaultPath</term>
             <listitem>
               <synopsis>DefaultPath=defaultpath (value set by configure)</synopsis>
@@ -5927,7 +5991,7 @@
               </para>
             </listitem>
           </varlistentry>
-
+                    
           <varlistentry>
             <term>config_button</term>
             <listitem>
@@ -5936,6 +6000,15 @@
               </para>
             </listitem>
           </varlistentry>
+          
+          <varlistentry>
+            <term>custom_cmd_button</term>
+            <listitem>
+              <para>
+                Executes the custom command.
+              </para>
+            </listitem>
+          </varlistentry>
 
           <varlistentry>
             <term>disconnect_button</term>
@@ -6125,6 +6198,10 @@
           &quot;true&quot; in the GDM configuration.
         </para>
         <para>
+          <filename>custom_cmd</filename>, if CustomCommand is specified in
+          the GDM configuration.
+        </para>
+        <para>
           <filename>halt</filename>, if HaltDaemon is specified in
           the GDM configuration.
         </para>
@@ -6331,6 +6408,9 @@
           <filename>config</filename>, _(&quot;_Configure&quot;
         </para>
         <para>
+          <filename>custom_cmd</filename>, _(&quot;_Custom&quot;
+        </para>
+        <para>
           <filename>disconnect</filename>, _(&quot;D_isconnect&quot;
         </para>
         <para>
@@ -6378,6 +6458,20 @@
 &lt;stock type=&quot;welcome-label&quot;&gt;
 </screen>
         </para>
+        
+        <para>
+          Note:
+        </para>
+        <para>
+          For:
+          <screen>
+            &lt;stock type=&quot;custom_cmd&quot;&gt;
+          </screen>
+        </para>
+        <para>
+          Value defined by <filename>CustomCommandLabel</filename> in the GDM configuration
+          will override the default stock label.
+        </para>
       </sect3>
 
       <sect3 id="customwidgetry">
@@ -6855,8 +6949,36 @@
         and not all of them have to be on all the time.  You could also have
         one of the X terminals handle indirect XDMCP queries and serve up the
         chooser to the other X terminals.
+      </para>      
+    </sect2>
+    
+    <sect2 id="customcommand">
+      <title>Defining Custom Command Option</title>
+      
+      <para>
+        Suppose you want to add a command to the login manager that 
+        will give you the oportunity to boot into other operating system such as Windows.
+        You need to add the following options into the <filename>[daemon]</filename> 
+        section of your GDM configuration file.
+        
+<screen>
+[daemon]
+CustomCommand=/sbin/rebootwin;/usr/local/sbin/rebootwin
+CustomCommandLabel=_Windows
+CustomCommandLRLabel=Reboot into _Windows
+CustomCommandText=Are you sure you want to restart the computer into Windows?
+CustomCommandTooltip=Restarts the computer into Windows
+</screen>
+        Where <filename>/sbin/rebootwin</filename> and 
+        <filename>/usr/local/sbin/rebootwin</filename> are the locations of the scripts 
+        that will actually perform the reboot action.
+      </para>
+      <para>
+        Note, that besides being able to customise this option to reboot into different operating systems
+        you can also use it for your own custom behaviours that you want to run before the logon. 
       </para>
     </sect2>
+    
   </sect1>
 
   <sect1 id="troubleshooting">
