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

List:       kde-core-devel
Subject:    [PATCH] Set --workdir when executing a service with konsole
From:       Alex Merry <kde () randomguy3 ! me ! uk>
Date:       2008-08-06 18:17:26
Message-ID: 200808061917.31097.kde () randomguy3 ! me ! uk
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


This stems from bug #162183 (https://bugs.kde.org/show_bug.cgi?id=162183)

Basically, when a script is executed by KLauncher using a .desktop file that 
has Terminal=1 set and a working path set, it does a chdir then executes a 
terminal program.

This is fine with most terminal programs, but konsole ignores the parent 
process working directory, and instead goes straight to your home directory.  
The --workdir option can be used to change this behaviour, as KToolInvocation 
does.  However, KLauncher uses KRun which has its own logic for constructing a 
terminal command line.

The attached patch fixes this, but I'm not sure whether including another 
macro (%w for working directory) is kosher.  Is it OK, and if so should I 
backport it to 4.1?

Alex



-- 
Proud KDE hacker: http://www.kde.org
Get KDE 4.1 - out now!
Arch Linux: perfect for geeks like me - http://www.archlinux.org
OpenSUSE: just works - http://www.opensuse.org


["krun-konsole-workdir.diff" (text/x-patch)]

Index: krun.cpp
===================================================================
--- krun.cpp	(revision 842930)
+++ krun.cpp	(working copy)
@@ -241,6 +241,9 @@ KRunMX1::expandEscapedMacro( const QStri
       kWarning() << "-miniicon isn't supported anymore (service"
                   << service.name() << ')';
       break;
+   case 'w':
+      ret << service.path().replace( '%', "%%" );
+      break;
    case 'u':
    case 'U':
       hasUrls = true;
@@ -423,8 +426,12 @@ QStringList KRun::processDesktopExec(con
   if (_service.terminal()) {
     KConfigGroup cg(KGlobal::config(), "General");
     QString terminal = cg.readPathEntry("TerminalApplication", "konsole");
-    if (terminal == "konsole")
+    if (terminal == "konsole") {
+      if (!_service.path().isEmpty()) {
+        terminal += " --workdir %w";
+      }
       terminal += " -caption=%c %i %m";
+    }
     terminal += ' ';
     terminal += _service.terminalOptions();
     if( !mx1.expandMacrosShellQuote( terminal ) ) {

["signature.asc" (application/pgp-signature)]

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

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