I am using gnome-terminal
to create a clickable desktop application. The application should be downloaded in a zip folder, with a sub-directory bin
containing my myapp.desktop
.
I would like to have a different directory somedir
in my zip file containing main application script and the icon for the application.
However, gnome-terminal
does not seem to work with relative paths. Here my myapp.desktop
:
[Desktop Entry]
Exec=gnome-terminal -e "bash -c -i 'exec $SHELL --init-file ../somedir/myscript.sh'"
Icon=../somedir/myicon.gif
Terminal=true
Type=Application
My question is: how can I pass the directory from which the application icon was clicked to gnome-desktop
? Or how can I organize my directory such that I do not have to have myicon.gif
and myscript.sh
in the same directory as myapp.desktop
?
I am aware of the --working-directory
argument to gnome-terminal
and tried to pass $PWD
, without success.
EDIT:
Related question: Desktop Launcher for Python Script Starts Program in Wrong Path (Linux)
A path can be specified in the .desktop
file, but again, it does not seem to deal with relative paths. If I add
Path=.
, it is not found.
.desktop
launcher question. The question is what information about the.desktop
file being launched does the launcher provide to the spawned process and what does it make available as variables/etc. for use in the.desktop
file. I'm going to guess that the answer is not much that is of use to you for this. – Turk.desktop
launcher issue. But event if I execute thegnome-terminal
command above without launcher, it only finds my--init-file
myscript.sh
if it is either in the same directory as mymyapp.desktop
or if I give an absolute path. – Poitiersbash --init-file ../somedir/myscript.sh
works well, but does not seem to work correctly with the paths ingnome-terminal
– Poitiersmyscript.sh
that will look formyscript.sh
in the current working directory of whatever process tries to use that path. I have no idea what working directory the launcher is going to use when it executes yourgnome-terminal
process. It might use the location of the.desktop
file. It might use your home directory. It might use/
. Or it might use anything else for that matter. – Turkcd -- "$(dirname "$0")"
in my clickable bash script, but I haven't gotten it to work with the launcher in ubuntu .yet – Poitiers