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 a开发者_开发问答ctually located and how can I get around this without having to specify an absolute path in the .desktop file?
$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.
精彩评论