1

I just recently downloaded a game called Starsector and instead of going into the folder every time and running ./starsector.sh, I want to create a desktop entry. Below is my current .desktop file called starsector.desktop:

[Desktop Entry]
Version=1.0
Name=Starsector
GenericName=Starsector
Exec=sh -c "cd /usr/games/starsector && sudo ./starsector.sh"
Terminal=false
Icon=/usr/games/starsector/graphics/icons/cargo/ai_core_alpha.png
Type=Application
Categories=Game

I have moved this file into ~/.local/share/applications. When copying the Exec line and running it in my shell, it runs the game perfectly fine, but when clicking on the icon it does nothing.

Things I have tried

I have tried to set Terminal=true
Run desktop-file-validate; there are no errors present
Adding exec permissions to the file
Copying file to the desktop and clicking "Allow launching"
Running gio set myapp.desktop metadata::trusted yes

As of now, the file permissions are -rw-rw-r--. I don't know if this is a file permission problem or simply a problem with the game executable itself somehow.

EDIT:

More things I have tried

Setting Exect=sh -c "cd /usr/game/starsector && sh ./starsector.sh
Changed owner and group of starsector.sh from root to my own user Changed owner and group of starsector.desktop from my own user to root:root

New contributor
Caleb Collier is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
4
  • I'm not sure, but I think you don't need sudo permission to execute it. Try changing your Exec line to Exec=sh "/usr/games/startsector/starsector.sh" ...
    – raylight
    May 14 at 6:12
  • That doesn't seem to work. When running that command from the command line, I get an error saying ./jre_linux/bin/java: not found. I've noticed that this only seems to happen when I try to directly run the .sh file. It looks like I first need to cd into the directory or it yells at me. May 14 at 6:47
  • 1
    I see, it's a java application... Does it work if you change it to Exec=sh -c "cd /usr/games/starsector && sh starsector.sh? This way it should work without having execution permission... When you execute it with ./starsector.sh you need at least -rwxrw-r-- permissions (which could be done with chmod +x /path/starsector.sh)
    – raylight
    May 14 at 7:02
  • That doesn't seem to work either. See my post again, I added more things I have tried. I kept wondering if it was a permissions problem, but that doesn't seem to be the case either. May 14 at 16:58

2 Answers 2

-1

change mode to execute startsector.sh

sudo chmod +x /usr/games/starsector/starsector.sh

change mode to execute startsector.desktop

sudo chmod +x /usr/share/applications/starsector.desktop

change EXEC inside desktop file

Exec=/usr/games/starsector/starsector.sh
1
  • Why would the .desktop file need to be executable? (And why move it from the user's home directory?) The shell script appears to already be executable, or otherwise sudo ./starsector.sh would not work.
    – Kusalananda
    May 14 at 8:28
-1

The solution was extremely simple. All I had to do was add #!/bin/bash at the top of the .desktop file and everything worked perfectly.

New contributor
Caleb Collier is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2
  • 1
    At the top of the .desktop file? Why? It's not a bash script.
    – Kusalananda
    May 14 at 20:08
  • Honestly, I'm trying to figure this out myself. When the actual game is run, I am running starsector.sh which is a bash script. The only thing I can guess is that I needed to let it know that I'm going to be executing a shell script with the Exec line. It's very weird, but it works perfectly. 2 days ago

Your Answer

Caleb Collier is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.