Problems creating a desktop entry for a shell script
Solution 1
Here are some tips that can help you solve your problem:
- Replace
Exec=/path/shell.sh
withExec=sh /path/shell.sh
orExec=bash /path/shell.sh
-
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
- use full paths in your shell file, e.g., in
java -jar foo.java
you need to replacefoo.java
with/full/path/to/foo.java
- 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;
Related videos on Youtube
iceboal
Updated on September 18, 2022Comments
-
iceboal over 1 year
I did the following procedures to create a application launcher but it doesn't work.
create shell script named
shell.sh
with the following content:java -jar foo.jar
- Added execution permission:
sudo chmod +x shell.sh
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 over 11 yearsThanks. I've tried but the problem remains. Maybe jar file couldn't be executed with desktop application launcher?
-
iceboal over 11 yearsI used
Exec = java -jar /path/foo.jar
and it work. Thanks! So what's wrong with the shell script? -
geethujoseph over 11 yearsYou 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 almost 9 yearsThis did it for me, primarily you need the Path set