From 8e0c79261ba55d891129fc7790d81e458c93cf38 Mon Sep 17 00:00:00 2001 From: xwizard Date: Sun, 10 Feb 2013 17:31:00 +0100 Subject: [PATCH] Adds support for Desktop Enty's Path Fixes https://bugs.launchpad.net/linuxmint/+bug/1120639 Changes: - Added appPath to ApplicationLauncher in easybutton.py - Added new commandCwd argument to Exec in execute.py (defaults to None) - ApplicationLauncher.execute() now passes CWD to execute.Exec --- usr/lib/linuxmint/mintMenu/plugins/easybuttons.py | 5 +++-- usr/lib/linuxmint/mintMenu/plugins/execute.py | 13 +++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py index f5b00ac..554cf89 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py +++ b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py @@ -288,6 +288,7 @@ class ApplicationLauncher( easyButton ): self.appCategories = desktopItem.getCategories() self.appGnomeDocPath = desktopItem.get( "X-MATE-DocPath" ) or "" self.useTerminal = desktopItem.getTerminal() + self.appPath = desktopItem.getPath() if not self.appGnomeDocPath: self.appKdeDocPath = desktopItem.getDocPath() or "" @@ -369,9 +370,9 @@ class ApplicationLauncher( easyButton ): if self.appExec: if self.useTerminal: cmd = "x-terminal-emulator -e \"" + self.appExec + "\"" - Execute(cmd) + Execute(cmd, self.appPath) else: - Execute(self.appExec) + Execute(self.appExec, self.appPath) def uninstall (self, *args ): Execute("gksu /usr/lib/linuxmint/mintMenu/mintRemove.py " + self.desktopFile) diff --git a/usr/lib/linuxmint/mintMenu/plugins/execute.py b/usr/lib/linuxmint/mintMenu/plugins/execute.py index 30658bf..ba9136a 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/execute.py +++ b/usr/lib/linuxmint/mintMenu/plugins/execute.py @@ -14,16 +14,25 @@ def RemoveArgs(Execline): return NewExecline # Actually execute the command -def Execute( cmd ): +def Execute( cmd , commandCwd=None): + if not commandCwd: + cwd = os.path.expanduser( "~" ); + else: + tmpCwd = os.path.expanduser( commandCwd ); + if (os.path.exists(tmpCwd)): + cwd = tmpCwd + if isinstance( cmd, str ): if (cmd.find("/home/") >= 0) or (cmd.find("su-to-root") >= 0) or (cmd.find("\"") >= 0): print "running manually..." + os.chdir(cwd) os.system(cmd + " &") return True cmd = cmd.split() cmd = RemoveArgs(cmd) + try: - os.chdir( os.path.expanduser( "~" ) ) + os.chdir( cwd ) subprocess.Popen( cmd ) return True except Exception, detail: