Problems creating a desktop entry for a shell script

7,138

Solution 1

Here are some tips that can help you solve your problem:

  1. Replace Exec=/path/shell.sh with Exec=sh /path/shell.sh or Exec=bash /path/shell.sh
  2. Add execution permission to the .desktop file

    sudo chmod +x /usr/share/application/<your_desktop_file>
    

Also unless you want that launcher to be available system-wide (ie: to all users) you can place the .desktop file in ~/.local/share/applications. As that folder is located in your home folder you don't need sudo to create/edit the file.

Solution 2

I don't know what's wrong with your entry, but I use the following app to create custom launchers. works in Unity too:

http://linux-apps.com/content/show.php/Desktop+Entry+Editor?content=147818

Desktop Entry Editor is a GUI application for editing and creating application launchers for GNOME, KDE, XFCE, and any other desktop environment implementing the Desktop Entry Specification from freedesktop.org.

Solution 3

Be sure to check that you either

  1. use full paths in your shell file, e.g., in java -jar foo.java you need to replace foo.java with /full/path/to/foo.java
  2. set the Path property of the desktop entry, which defines the working directory for your script, i.e., the script executes relative to the specified working directory.

If you follow the second option your desktop entry will look something like this

[Desktop Entry]
Name=foo
Terminal=false
Exec=/full/path/to/shell.sh
Path=/full/path/to
Type=Application
Icon=/full/path/to/icon.png
Categories=Utility;
Share:
7,138

Related videos on Youtube

iceboal
Author by

iceboal

Updated on September 18, 2022

Comments

  • iceboal
    iceboal over 1 year

    I did the following procedures to create a application launcher but it doesn't work.

    1. create shell script named shell.sh with the following content:

      java -jar foo.jar
      
    2. Added execution permission: sudo chmod +x shell.sh
    3. Created .desktop file in /usr/share/applications/ with the content:

      [Desktop Entry]
      Name=foo
      Terminal=false
      Exec=/path/shell.sh
      Type=Application
      Icon=/path/icon.png
      Categories=Utility;
      

    Then I have an application with icon, but it couldn't run, while double click shell.sh works. What's wrong?

  • iceboal
    iceboal over 11 years
    Thanks. I've tried but the problem remains. Maybe jar file couldn't be executed with desktop application launcher?
  • iceboal
    iceboal over 11 years
    I used Exec = java -jar /path/foo.jar and it work. Thanks! So what's wrong with the shell script?
  • geethujoseph
    geethujoseph over 11 years
    You should have some problem in the path used in Exec. I created a similar setup and if the .desktop and the .sh files are both executable it works. Check if you have spaces or some special characters in the path that should be escaped.
  • thouliha
    thouliha almost 9 years
    This did it for me, primarily you need the Path set