diff -rupN /tmp/x2goclient-3.01/configdialog.cpp x2goclient-3.01/configdialog.cpp
--- /tmp/x2goclient-3.01/configdialog.cpp	2009-11-26 23:22:51.000000000 +0100
+++ x2goclient-3.01/configdialog.cpp	2011-01-21 17:49:11.000000000 +0100
@@ -54,6 +54,10 @@ ConfigDialog::ConfigDialog ( QWidget * p
 	st.beginGroup ( "settings" );
 #endif
 
+	trayIconEnabledEdit = new QCheckBox ( tr ( "Minimize to tray after establishing connection" ) );
+	trayIconEnabledEdit->setChecked ( st.value ( "trayEnabled", false ).toBool() );
+	frLay->addWidget(trayIconEnabledEdit);
+
 #ifdef USELDAP
 	if ( !embedMode )
 	{
@@ -328,6 +332,8 @@ void ConfigDialog::slot_accepted()
 	st.beginGroup ( "settings" );
 #endif
 
+	st.setValue ( "trayEnabled", trayIconEnabledEdit->isChecked() );
+	
 #ifdef USELDAP
 	if ( !embedMode )
 	{
diff -rupN /tmp/x2goclient-3.01/configdialog.h x2goclient-3.01/configdialog.h
--- /tmp/x2goclient-3.01/configdialog.h	2009-11-10 22:38:21.000000000 +0100
+++ x2goclient-3.01/configdialog.h	2011-01-21 17:45:17.000000000 +0100
@@ -77,6 +77,8 @@ class ConfigDialog : public QDialog
 		ConnectionWidget* conWidg;
 		SettingsWidget* setWidg;
 
+		QCheckBox *trayIconEnabledEdit;
+
 	public slots:
 		void slot_accepted();
 		void slot_checkOkStat();
diff -rupN /tmp/x2goclient-3.01/onmainwindow.cpp x2goclient-3.01/onmainwindow.cpp
--- /tmp/x2goclient-3.01/onmainwindow.cpp	2009-11-27 23:55:06.000000000 +0100
+++ x2goclient-3.01/onmainwindow.cpp	2011-01-21 17:57:02.000000000 +0100
@@ -388,6 +383,34 @@ ONMainWindow::ONMainWindow ( QWidget *pa
 	          SLOT ( slot_resize ( const QSize ) ) );
 
 	slot_resize ( fr->size() );
+
+	if(!trayEnabled){
+		trayIconActiveConnectionMenu = NULL;
+		trayIconConnectionMenu = NULL;
+		trayIcon = NULL;
+	}
+	else{
+		// setup the tray icon context menu
+		QMenu *trayIconMenu = new QMenu(this);
+		trayIconMenu->addAction(tr("Open client"),
+														this, SLOT(show()));
+		trayIconActiveConnectionMenu = trayIconMenu->addMenu(tr("Active connections"));
+		trayIconConnectionMenu = trayIconMenu->addMenu(tr("Open connection"));
+
+		trayIconMenu->addSeparator();
+		trayIconMenu->addAction(tr("Quit"),
+														this, SLOT(trayQuit()));
+
+		// setup the tray icon itself
+		trayIcon = new QSystemTrayIcon(this);
+		connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
+						this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
+		connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(trayMessageClicked()));
+		trayIcon->setContextMenu(trayIconMenu);
+		trayIcon->setIcon(QIcon ( ":icons/128x128/x2go.png") );
+		trayIcon->setToolTip(tr("Left click to open the X2GoClient window or right click to get the context menu."));
+		trayIcon->show();
+	}
 }
 
 ONMainWindow::~ONMainWindow()
@@ -587,7 +610,7 @@ void ONMainWindow::initWidgetsNormal()
 	connect ( act_edit,SIGNAL ( triggered ( bool ) ),this,
 	          SLOT ( slot_manage() ) );
 	connect ( act_exit,SIGNAL ( triggered ( bool ) ),this,
-	          SLOT ( close() ) );
+	          SLOT ( trayQuit() ) );
 	connect ( act_tb,SIGNAL ( toggled ( bool ) ),this,
 	          SLOT ( displayToolBar ( bool ) ) );
 	stb=addToolBar ( tr ( "Show toolbar" ) );
@@ -746,6 +769,26 @@ void ONMainWindow::slot_resize ( const Q
 
 void ONMainWindow::closeEvent ( QCloseEvent* event )
 {
+	// do not exit application, if tray icon is visible
+	if(!trayIcon || !trayIcon->isVisible()){
+		trayQuit();
+	}
+	else{
+//     if(!trayQuitInfoShown){
+//       QMessageBox::information(this, windowTitle(),
+//                                tr("The program will keep running in the "
+//                                        "system tray. To terminate the program, "
+//                                        "choose <b>Quit</b> in the context menu "
+//                                        "of the system tray entry."));
+//       trayQuitInfoShown = true;
+//     }
+    hide();
+    event->ignore();
+  }
+}
+
+void ONMainWindow::trayQuit()
+{
 	if ( !startMaximized && !startHidden && !embedMode )
 	{
 #ifndef Q_OS_WIN
@@ -761,9 +804,9 @@ void ONMainWindow::closeEvent ( QCloseEv
 		st.setValue ( "mainwindow/pos",QVariant ( pos() ) );
 		st.setValue ( "mainwindow/maximized",
 		              QVariant ( isMaximized() ) );
+// st.setValue ( "trayQuitInfoShown", trayQuitInfoShown);
 		st.sync();
 	}
-	QMainWindow::closeEvent ( event );
 	if ( nxproxy!=0l )
 	{
 		if ( nxproxy->state() ==QProcess::Running )
@@ -823,6 +866,10 @@ void ONMainWindow::closeEvent ( QCloseEv
 		closeEmbedWidget();
 #endif
 	}
+
+	// is used, because closeEvent() only hides the window
+	// because of the QSystemTrayIcon
+	qApp->quit();
 }
 
 void ONMainWindow::loadSettings()
@@ -875,6 +922,9 @@ void ONMainWindow::loadSettings()
 #endif
 	showToolBar=st1.value ( "toolbar/show", ( QVariant ) true ).toBool();
 
+	// tray stuff
+	trayEnabled = st1.value( "trayEnabled", false ).toBool();
+// 	trayQuitInfoShown = st1.value( "trayQuitInfoShown", false ).toBool();
 }
 QString ONMainWindow::iconsPath ( QString fname )
 {
@@ -2135,6 +2185,7 @@ bool ONMainWindow::startSession ( const 
 		slot_listSessions ( false,message,0 );
 		return false;
 	}
+
 	return true;
 }
 
@@ -3517,6 +3568,9 @@ void ONMainWindow::slot_retResumeSess ( 
 			}
 		}
 	}
+
+	if(trayEnabled)
+		hide();
 }
 
 
@@ -7957,3 +8011,28 @@ void ONMainWindow::slotHideEmbedToolBarT
 	showTbTooltip=false;
 	QToolTip::hideText();
 }
+
+void ONMainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason )
+{
+	 switch(reason){
+// use single left click on unix
+// and double click on windows (Is it standard behaviour conform?)
+#ifdef Q_OS_UNIX
+    case QSystemTrayIcon::Trigger:
+#else
+    case QSystemTrayIcon::DoubleClick:
+#endif
+			if(isVisible())
+				hide();
+			else
+				show();
+      break;
+		default:
+			break;
+  }
+}
+
+void ONMainWindow::trayMessageClicked()
+{
+	
+}
diff -rupN /tmp/x2goclient-3.01/onmainwindow.h x2goclient-3.01/onmainwindow.h
--- /tmp/x2goclient-3.01/onmainwindow.h	2009-11-26 22:20:26.000000000 +0100
+++ x2goclient-3.01/onmainwindow.h	2011-01-21 17:29:01.000000000 +0100
@@ -30,6 +30,7 @@
 #include "LDAPSession.h"
 #include "embedwidget.h"
 #include <QToolBar>
+#include <QSystemTrayIcon>
 
 #ifdef Q_OS_WIN
 #include <windows.h>
@@ -58,6 +59,7 @@ class QModelIndex;
 class sshProcess;
 class IMGFrame;
 class QStandardItemModel;
+class QMenu;
 struct user
 {
 	int uin;
@@ -507,6 +509,13 @@ class ONMainWindow : public QMainWindow
 		QString defaultSessionId;
 		QString defaultUserName;
 		bool defaultUser;
+
+		// Tray icon stuff
+		QSystemTrayIcon *trayIcon;
+    QMenu *trayIconActiveConnectionMenu, *trayIconConnectionMenu;
+		bool trayEnabled;
+// 		bool trayQuitInfoShown;
+		
 		SessionButton* createBut ( const QString& id );
 		void placeButtons();
 		QString getKdeIconsPath();
@@ -563,6 +572,23 @@ class ONMainWindow : public QMainWindow
 		void displayToolBar ( bool );
 		void showSessionStatus();
 
+		// tray icon stuff
+		/**
+			* @brief Is called when clicked on the QSystemTrayIcon.
+			*/
+		void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
+		/**
+			* @brief Is called when a message from QSystemTrayIcon is clicked.
+			*/
+		void trayMessageClicked();
+		/**
+			* @brief Is called when Quit from context menu of QSystemTrayIcon is clicked.
+			*
+			* Prepares everything to quit the application. It has the functionality of
+			* the old (before QSystemTrayIcon is used) closeEvent() function.
+			*/
+		void trayQuit();
+
 	public slots:
 		void slot_config();
 		void slotNewSession();