Score:0

How to make a .desktop file work on Ubuntu 22.04 where the executable file has a dependency on a folder?

ee flag

I tried to create a .desktop file for my 2D shooting game made with sdl2. the .desktop file looks like this

[Desktop Entry]
Version=1.0
Name=The Hunt For Red October
Comment=2D shooting game
Exec=/home/araf/Projects/The_Hunt_For_Red_October/a.out 
Icon=/home/araf/Pictures/hunt for red october intro.png
Terminal=false
Type=Application
Categories=Utility;Application;

after that I checked the Allowed executing file as program & Allow launching. but it was not executing rather a black screen popped out and instantly go away. Later I figured out It was because that a.out has a dependency on a folder /home/araf/Projects/The_Hunt_For_Red_October/assets where all the media files are located so a.out file is terminating. So, How can I include that folder with it and make it work?

hr flag
Have you tried using a `Path` specification? See for example [How to create a .desktop unity launcher that starts an executable in a specific working directory](https://askubuntu.com/questions/191100/how-to-create-a-desktop-unity-launcher-that-starts-an-executable-in-a-specific)
user535733 avatar
cn flag
Executable files don't have "dependencies" (deb packages do). If your code cannot locate the expected files, that seems like a bug in your code. Does not seem like an Ubuntu issue.
Score:0
ee flag

I fixed that problem. After seeing an answer in another question here I figured out what I missing was that I have to run the executable file in the folder where the /home/araf/Projects/The_Hunt_For_Red_October/assets folder is located. To do this all I needed was to add an extra line


Path=/home/araf/Projects/The_Hunt_For_Red_October/

in the .desktop file indicating the folder where the a.out file will run. as assets folder is also in the same folder so now a.out can access the media file from assets folder and the file executes without error.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.