Tuesday, April 23, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 7503  / 1 Year ago, mon, december 19, 2022, 8:55:50

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?


More From » command-line

 Answers
4

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


[#24180] Monday, December 19, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
oraoming

Total Points: 354
Total Questions: 105
Total Answers: 124

Location: Iraq
Member since Sat, Apr 3, 2021
3 Years ago
oraoming questions
Fri, Aug 20, 21, 10:08, 3 Years ago
Mon, May 24, 21, 21:56, 3 Years ago
Mon, Dec 12, 22, 23:21, 1 Year ago
Mon, Sep 12, 22, 11:38, 2 Years ago
;