[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    screen sessions fixlet
From:       Malte Starostik <malte () kde ! org>
Date:       2002-10-07 18:37:36
[Download RAW message or body]

Hi,

the attached patch fixes screen session handling on distros which use some 
weird hack to set SCREENDIR only when first needed. (Mandrake and AFAIK also 
RedHat, maybe anything RH based?)
It needs to pass the env var since the command is run via $SHELL -c so the 
function from /etc/profile.d/screen.sh won't be loaded and the screen binary 
won't find the FIFO without it.
Please review.

-Malte
["konsole.diff" (text/x-diff)]

Index: konsole.cpp
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/konsole.cpp,v
retrieving revision 1.337
diff -u -3 -d -p -r1.337 konsole.cpp
--- konsole.cpp	2002/09/18 16:13:39	1.337
+++ konsole.cpp	2002/10/07 18:34:21
@@ -2317,7 +2317,7 @@ void Konsole::loadSessionCommands()
                         i18n("Shell at Bookmark"), m_bookmarksSession);
 }
 
-void Konsole::addScreenSession(const QString &socket)
+void Konsole::addScreenSession(const QString &path, const QString &socket)
 {
   KTempFile *tmpFile = new KTempFile();
   tmpFile->setAutoDelete(true);
@@ -2326,7 +2326,8 @@ void Konsole::addScreenSession(const QSt
   co->writeEntry("Name", socket);
   QString txt = i18n("Screen is a program controlling screens!", "Screen at %1").arg(socket);
   co->writeEntry("Comment", txt);
-  co->writeEntry("Exec", QString::fromLatin1("screen -r %1").arg(socket));
+  co->writeEntry("Exec", QString::fromLatin1("SCREENDIR=%1 screen -r %2")
+    .arg(path).arg(socket));
   QString icon = "openterm"; // FIXME use another icon (malte)
   cmd_serial++;
   m_session->insertItem( SmallIconSet( icon ), txt, cmd_serial, cmd_serial - 1 );
@@ -2343,6 +2344,10 @@ void Konsole::loadScreenSessions()
   QCString screenDir = getenv("SCREENDIR");
   if (screenDir.isEmpty())
     screenDir = QFile::encodeName(QDir::homeDirPath()) + "/.screen/";
+  // Some distributions add a shell function called screen that sets
+  // $SCREENDIR to ~/tmp. In this case the variable won't be set here.
+  if (!QFile::exists(screenDir))
+    screenDir = QFile::encodeName(QDir::homeDirPath()) + "/tmp/";
   QStringList sessions;
   // Can't use QDir as it doesn't support FIFOs :(
   DIR *dir = opendir(screenDir);
@@ -2368,7 +2373,7 @@ void Konsole::loadScreenSessions()
   }
   resetScreenSessions();
   for (QStringList::ConstIterator it = sessions.begin(); it != sessions.end(); ++it)
-    addScreenSession(*it);
+    addScreenSession(screenDir, *it);
 }
 
 void Konsole::resetScreenSessions()
Index: konsole.h
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/konsole.h,v
retrieving revision 1.137
diff -u -3 -d -p -r1.137 konsole.h
--- konsole.h	2002/09/30 06:54:58	1.137
+++ konsole.h	2002/10/07 18:34:21
@@ -221,7 +221,7 @@ private:
   void buildSessionMenus();
   void addSessionCommand(const QString & path);
   void loadSessionCommands();
-  void addScreenSession(const QString & socket);
+  void addScreenSession(const QString & path, const QString & socket);
   void resetScreenSessions();
 
   QPtrDict<TESession> action2session;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic