From kde-core-devel Mon Oct 07 18:37:36 2002 From: Malte Starostik Date: Mon, 07 Oct 2002 18:37:36 +0000 To: kde-core-devel Subject: screen sessions fixlet X-MARC-Message: https://marc.info/?l=kde-core-devel&m=103401589028296 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_wRdo9xXrrK2Xqwu" --Boundary-00=_wRdo9xXrrK2Xqwu Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, the attached patch fixes screen session handling on distros which use some= =20 weird hack to set SCREENDIR only when first needed. (Mandrake and AFAIK als= o=20 RedHat, maybe anything RH based?) It needs to pass the env var since the command is run via $SHELL -c so the= =20 function from /etc/profile.d/screen.sh won't be loaded and the screen binar= y=20 won't find the FIFO without it. Please review. =2DMalte --Boundary-00=_wRdo9xXrrK2Xqwu Content-Type: text/x-diff; charset="us-ascii"; name="konsole.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="konsole.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 action2session; --Boundary-00=_wRdo9xXrrK2Xqwu--