Hi all. I have written some software which runs fine when executed from the terminal. It needs to access some resources which live in an imaginatively titled "resources" folder in the same folder where the executable lives. I wanted to have a desktop launcher for this so created a .desktop file which looks like this:
[Desktop Entry]
Type=Application
Terminal=true
Name=the_executable
Exec=/home/me/path/to/the_executable
At present it still partly needs a terminal to be running (for couts and a few cins) hence the "true" above.
However when launched this way the executable fails to find its resources. I assume that's because somehow we are still not in the home directory of the executable. Is there a syntax to set this in the .desktop file? If not do I perhaps need to add something to my PATH variable (which seems an inelegant way of doing things).
I'm using Mint 18.2 (64-bit version).
Thanks in advance!
Syntax for .desktop files
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Syntax for .desktop files
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Syntax for .desktop files
I've not had that need, but I think if you used this it might work:
[Desktop Entry]
Type=Application
Terminal=true
Name=the_executable
Path=/home/me/path/to
Exec=the_executable
[Desktop Entry]
Type=Application
Terminal=true
Name=the_executable
Path=/home/me/path/to
Exec=the_executable
Re: Syntax for .desktop files
Thanks for your reply. No: unfortunately if I do that there simply pops up a dialogue box saying "there was an error launching the application". Is "path" a valid key in the .desktop syntax? If so I am doing something wrong. Without this, the application executes fine to begin with, but complains that it can't find certain files located in the resources folder of its home directory.
Re: Syntax for .desktop files
Yes to the Path question. I got it from here: https://wiki.archlinux.org/index.php/Desktop_entries
Sorry that I can help any further.
Sorry that I can help any further.
Re: Syntax for .desktop files
Indeed it is. Thank you for your time looking into this.
The issue persists. The .desktop file currently stands at
[Desktop Entry]
Type=Application
Encoding=UTF-8
Version=1.0
Terminal=true
Name=the_executable
Exec=/home/me/path/to/the_executable
I would like to understand why the program runs perfectly from terminal, but cannot find files in its home directory when executed from this desktop launcher.
(for clarification: It's a fairly basic c++ program which merely tries to open various files whose path it is given as a c string.)
The issue persists. The .desktop file currently stands at
[Desktop Entry]
Type=Application
Encoding=UTF-8
Version=1.0
Terminal=true
Name=the_executable
Exec=/home/me/path/to/the_executable
I would like to understand why the program runs perfectly from terminal, but cannot find files in its home directory when executed from this desktop launcher.
(for clarification: It's a fairly basic c++ program which merely tries to open various files whose path it is given as a c string.)
Re: Syntax for .desktop files
Horse's mouth with respect to .desktop files is https://standards.freedesktop.org/deskt ... index.html.
Indeed it mentions the Path key so wouldn't know why that's not working for you: https://standards.freedesktop.org/deskt ... 01s06.html
Indeed it mentions the Path key so wouldn't know why that's not working for you: https://standards.freedesktop.org/deskt ... 01s06.html
Re: Syntax for .desktop files
Hi everyone - in case anyone else had an analogous problem I will post the solution I found. The software I wrote needed to access external data which in my case consisted of some .json files. If you want to do this you need to specify in the desktop entry file the MIME type(s) your application will be working with. An incomplete list may be found at https://developer.mozilla.org/en-US/doc ... MIME_types for example. So in my case the desktop file required the line
where the value(s) on the right hand side will be application-dependent.
The moral of the story for me is that a program in and of itself may be happy working with other resources, but for some kinds of resources the .desktop file will
also need to be told what those are.
Thank for the other comments, if I had mentioned this aspect of using json files I am sure you would have told me straight away (but, if I had realised it myself I would not have posted). Please all do post corrections if the 'solution' I have posted is misinformed in any way.
Code: Select all
MimeType=application/json
The moral of the story for me is that a program in and of itself may be happy working with other resources, but for some kinds of resources the .desktop file will
also need to be told what those are.
Thank for the other comments, if I had mentioned this aspect of using json files I am sure you would have told me straight away (but, if I had realised it myself I would not have posted). Please all do post corrections if the 'solution' I have posted is misinformed in any way.