From 30d0261cd3efa7e4e488a5978c239b18be90bdff Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Tue, 25 Feb 2014 18:02:39 +0000 Subject: [PATCH] If .desktop file set Path key, obey to it and change current working directory. --- ede-launch/ede-launch.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ede-launch/ede-launch.cpp b/ede-launch/ede-launch.cpp index 04280ef..0218d2a 100644 --- a/ede-launch/ede-launch.cpp +++ b/ede-launch/ede-launch.cpp @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright (C) 2012-2013 Sanel Zukan + * Copyright (C) 2012-2014 Sanel Zukan * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -407,6 +407,18 @@ static bool start_desktop_file(const char *cmd) { } char buf[PATH_MAX]; + + /* + * Determine working directory and set it first, to reuse buffer. Note that + * it will override working directory path set from command line. + */ + if(d.path(buf, PATH_MAX)) { + errno = 0; + if(chdir(buf) < 0) { + alert(_("Unable to change directory to '%s'. Got '%s' (%i)"), buf, strerror(errno), errno); + } + } + if(!d.exec(buf, PATH_MAX)) { alert(_("Unable to run '%s'.\nProbably this file is malformed or 'Exec' key has non-installed program"), cmd); return false;