Ubuntu – Problems creating a desktop entry for a shell script

iconsscripts

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?

Best Answer

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.

Related Question