views:

148

answers:

1

I've developed an application in Qt which uses a launch script, myapp.sh. I've created a .desktop file which launches this script, and set:

Command: $PWD/myapp.sh

Work path: $PWD

However, $PWD prints my home directory when I launch the .desktop file, resulting in attempting to launch ~/myapp.sh rather than ~/Development/build-directory/bin/myapp.sh (that directory being where the .desktop file resides). Why isn't it correctly setting the working directory to where the .desktop file is actually located and how can I get around this without having to specify an absolute path in the .desktop file?

+1  A: 

$PWD holds the current working directory of the shell, which has nothing to do with the location of the .desktop file.. One way you can do this is with:

Exec=$(dirname %k)/myapp.sh

From the spec, %k is "The location of the desktop file as either a URI (if for example gotten from the vfolder system) or a local filename or empty if no location is known." So this is myapp.sh in the same directory.

Matthew Flaschen
+1 Thanks, this works. However I do get two tabs in the taskbar if "enable launch feedback" is selected... any idea why?
Jake Petroules
It may be showing launch feedback for the `dirname` executable. I don't know of a work-around right now.
Matthew Flaschen
Simply not showing launch feedback will be an acceptable workaround at this time, I suppose. Thanks for your help though. :)
Jake Petroules