How Can I Run an Shell Script With .desktop Config File?
Solution 1
Thank's Everyone for the help. I realized that I had something wrong with my .desktop
file. I noticed that the properties of the .desktop file were different to that of the other .desktop files in /usr/share/applications
, in it that there were no Description, Command or Comment text areas in mine.
I saved the .desktop file of Color Picker to the desktop and I substituted my information in, which made it work.
This is what the properties->Basic of the .desktop file is.
The Script
[Desktop Entry]
Name=Minecraft-Server Comment=Run the Minecraft
Craftbukkit Server
Icon=/home/ubuntu-gnome/Documents/Craftbukkit/craftbukkit.png
Exec='/home/ubuntu-gnome/Documents/Craftbukkit/run.sh'
Terminal=true
Type=Application
Categories=Minecraft;Server;CraftBukkit;
Solution 2
This is what I would use for creating the ".desktop" file:
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Name=MY APPLICATION NAME
Comment=THINGS I HAVE TO SAY ABOUT THE APPLICATION
Exec=sh -c "cd /PATH_TO_SH_FILE_FOLDER; FILENAME.sh"
Categories=ENGINERRING;GRAPHICS;ETC
Icon=/PATH_TO_ICON_IMAGE_FILE
For above, change the all-capital portions of the code to fit your context (which doesn't have to be all-capital). You can add Terminal = true
if you want to see the terminal window.
Modified from an answer I gave to a related question here: Link to .exe doesn't launch Wine
Solution 3
Few potential issues:
-
Your script needs a shebang on its first line... it should look like:
#!/bin/bash /usr/bin/java ...
-
Your script needs to be marked as executable:
chmod +x /path/to/script.sh
-
Your
.desktop
file also needs to be executable (security policy stuff apparently):chmod +x /path/to/desktop-file.desktop
Related videos on Youtube
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
I am trying to run a shell script with a
.desktop
file but it doesn't seem to work, producing an error ofThere was an error launching the application
at each attempt. I have the sh and .desktop files set the executable..desktop file:
[Desktop Entry] Name=Craftbukkit Server Comment=run server Exec="/home/ubuntu-gnome/Documents/Craftbukkit/run.sh" Icon=/home/ubuntu-gnome/Documents/Craftbukkit/craftbukkit.png Terminal=true Type=Application
The script:
#!/bin/bash /usr/bin/java -Xmx1024M -Xms1024M -jar /home/ubuntu-gnome/Documents/Craftbukkit/craftbukkit.jar -o false
All paths are correct.
Methods I Have Tried:
Exec="/home/ubuntu-gnome/Documents/Craftbukkit/run.sh"
Exec='/home/ubuntu-gnome/Documents/Craftbukkit/run.sh'
Exec=/home/ubuntu-gnome/Documents/Craftbukkit/run
Exec="/home/ubuntu-gnome/Documents/Craftbukkit/run.sh"
Exec=gnome-terminal -e "/home/ubuntu-gnome/Documents/Craftbukkit/run.sh"
Exec=bash -c 'cd /home/ubuntu-gnome/Documents/Craftbukkit/ && ./run.sh'
Conspicuously, I have tried many methods. Can anyone assist me with a resolution to this?
-
Admin over 9 yearsYes It does. I have been using it from the terminal with
./run.sh
for many months now.
-
blade19899 over 9 yearsRegarding step 3. why question: Permission of a .desktop file
-
Jacob Vlijm over 9 yearsThe last one should not be necessary when run from Dash and stored in
~/.local.share/applications
or/usr/share/applications
(not on my system anyway) -
Admin over 9 yearsStill produces the same error.
-
Jacob Vlijm over 9 yearsthat is just replacing in OP's last attempt "&&" by ";". won't change anything.
-
Ronald Chua over 9 yearsWhoops, my bad. Thanks @JacobVlijm for pointing out. Glad it is sorted out anyway.