7

I have a .desktop file:

[Desktop Entry]
Type=Application
Terminal=true
Name=RunMe
Exec=run.sh

When I double click the .desktop file, I get There was an error launching the application.

my run.sh is:

#!/bin/sh
xulrunner-sdk/bin/xulrunner-stub --app xulrunner-sdk/bin/application.ini 2>~log.log

Double clicking on run.sh and clicking run runs the application fine. Both run.sh and my .desktop are executable.

What do I need to change in my desktop file to make this work?

2
  • 3
    Use a full pathname on the Exec line.
    – Jos
    Jul 11, 2014 at 9:58
  • I tried that, same issue, but ideally I want this to be portable anyway.
    – Kiksy
    Jul 11, 2014 at 10:21

4 Answers 4

7

To figure out what exactly is the error as you asked

What do I need to change in my desktop file to make this work?

After a lot of research, I found that you can indeed validate your desktop file with this command

desktop-file-validate your-file-here.desktop

This was the hidden command I was trying to find since hours. This, Saved my day :-)

This command will show you warning and errors wherever you have gone wrong. Credits : ubuntuforums

1
  • Great find, but it doesn't actually execute the Exec command. Oct 5, 2018 at 4:47
2

%k is the desktop file path, use it with sh to relative .desktop:

  • Change current working directory (pwd), Then run.sh & commands inside all will run from there:

    [Desktop Entry]
    Type=Application
    Terminal=true
    Name=Run Me
    Exec=sh -c "cd `dirname %k`; run.sh"
    
  • Otherwise, passing it as parameter to run.sh and use it explicitly when you need inside run.sh:

    run.desktop

        [Desktop Entry]
        Type=Application
        Terminal=true
        Name=Run Me
        Exec=sh -c "`dirname %k`/run.sh `dirname %k`"
    

    run.sh

        #!/bin/sh
        $1/xulrunner-sdk/bin/xulrunner-stub --app $1/xulrunner-sdk/bin/application.ini 2>$1/~log.log
    

Reference: How can I set the 'Path' variable in a .desktop file to be relative to the location where the desktop file is located?

2
  • 1
    Tried 'Exec=bash -c "export PATH=$PATH:dirname %k; sh run.sh;"' but still nothing happens on the double click.
    – Kiksy
    Jul 14, 2014 at 8:12
  • @Kiksy, I didn't notice that you are using other relative path inside run.sh. Change current working directory (pwd) should work, or passing it as parameter. Updated answer
    – user.dz
    Jul 14, 2014 at 12:00
1
  • Goto /usr/share/app-install/desktop
  • right click on your specific application
  • go to properties
  • copy the command section
  • execute same from terminal
-1
  1. Put your script, (the orig. one) in a bin directory in your PATH if not already.
  2. Rename the script & lose the extension, eg, run1
  3. edit your .desktop to reflect new name, eg. Exec=run1

Your Answer

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.