Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a .desktop file:

[Desktop Entry]

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

my is:

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

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

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

share|improve this question
Use a full pathname on the Exec line. – Jos Jul 11 '14 at 9:58
I tried that, same issue, but ideally I want this to be portable anyway. – Kiksy Jul 11 '14 at 10:21
up vote 0 down vote accepted

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

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

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


        [Desktop Entry]
        Name=Run Me
        Exec=sh -c "`dirname %k`/ `dirname %k`"

        $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?

share|improve this answer
Tried 'Exec=bash -c "export PATH=$PATH:dirname %k; sh;"' but still nothing happens on the double click. – Kiksy Jul 14 '14 at 8:12
@Kiksy, I didn't notice that you are using other relative path inside Change current working directory (pwd) should work, or passing it as parameter. Updated answer – Sneetsher Jul 14 '14 at 12:00
  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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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