I've downloaded the free and open-source image analysis software "Icy" (http://icy.bioimageanalysis.org/), and I can launch it by making the "icy.sh" file executable and double-clicking on it.

However if I create a shortcut to this file, I can't launch it, except if the shortcut is in the original folder. Here is a clue, that this is possibly due to the fact that "Java programs need to be started from within the directory in which their files exist.": https://help.ubuntu.com/community/HowToAddaLauncher

But I have no idea of how it actually works and how to solve that. If you have any idea that would be great :-)

Thanks guys!

share|improve this question
up vote 1 down vote accepted

when you open that icy.sh file, you can see

    java -jar updater.jar

So you can just modify (leafpad, gedit or any other text editor)your icy.desktop file to:

   [Desktop Entry]
   Name=ICY
   Exec=java -jar '/your/path/to/file/updater.jar' 
   Icon=your/path/to/icon
   Terminal=false
   Type=Application

With icy.sh set as executable and with shortcut created as:

   Exec=/your/path/to/file/icy.sh 

it didnt work, like in your case... this is workaround I would use

share|improve this answer
    
YES! I actually did that before checking your answer and it works fine, thanks! – Alexis Cllmb Apr 30 '15 at 15:02

Create a .desktop file:

[Desktop Entry]
Name=Icy
Exec=/bin/bash -c "cd /path/to/script/directory&&./icy.sh"
Type=Application
Terminal=false
  • Copy it into an empty file, save it as icy.desktop
  • Replace /path/to/script/directory by the actual path to the script's directory
  • Make it executable

Explanation

Desktop files (with the extension .desktop) can be used to perform all kinds of applications or tasks. To make it run shell commands, the format is:

Exec=/bin/bash -c "<command>"

The <command> in this case is:

cd /path/to/script/directory&&./icy.sh

In detail:

cd /path/to/script/directory

to cd to the script's directory, and subsequently:

./icy.sh

to run icy.sh from its own directory

Give the .desktop file an(other) icon:

The example file is a very basic one:

enter image description here

If you'd like the file to have another icon than the generic one, add a line (e.g.):

Icon=/path/to/icon.png

enter image description here

More on .desktop files and their required/optional entries here.

share|improve this answer
    
Very nice answer, it made my day :-) ! – Pekov Apr 19 '17 at 21:51

You can open the "shortcut" as a plain text using any text editor. When opened, you must change the path of the file. Probably now it's a relative path, so make it absolute to look like "./home/user/pathtofile/file.sh"

share|improve this answer

Your Answer

 
discard

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.