Aha - OK! The problem is the "press any key" bit that I advised you to add to the Exec= field in the .desktop file, after the main script has executed. So that's totally on me. Goes to show I'm not infallible! Ha ha.
You can only run one program/script in the Exec field. That's the reason for the error message.
The actual workaround I was thinking of, to prevent the window from quickly popping up and disappearing actually involves manually invoking a terminal in your .desktop file and then running your script in that.
So you'd change the following fields to this:
Code:
Exec=xterm -e '/usr/local/bin/yourExecutable; read -p "press any key to continue..." -n1 -s'
Terminal=false
Where yourExecutable is the name of the script/executable to run.
The reason we set Terminal to false above, is because we're now going to explicitly run xterm (A terminal that is commonly included by default in most Linux distros - even if it's NOT the systems default terminal.)
So your script will be running in a different terminal emulator. Which may not be an ideal solution.
I used xterm in the example, because it's commonly installed on most distros (or at least, it always used to be - might not be the case now), but you could substitute that for any other terminal emulator - you'd just have to look up the documentation for the terminal, in order to work out what flags you need to set in order to open the terminal and run a specific set of commands.
Also, in the above - if Terminal was set to
Terminal=true
- a default terminal window would popup which would run xterm. And because xterm is a graphical application, it would create it's own window. So setting Terminal to false, prevents the unnecessary default terminal from popping up.
Alternatively - another way around the problem, as I mentioned before would be to add a "read -p" command to your scripts, to pause the script.
e.g.
At the end of each of your scripts - have a line that reads:
Bash:
read -p "Press any key to continue..." -n1 -s
That way your .desktop files don't need to change. The Exec and Terminal fields would stay as:
Code:
Exec=/usr/local/bin/yourScript
Terminal=True
Where yourScript is substituted with the name of your script.
OR (this one might be a winner) - another way around the issue would be to create a wrapper script that takes a path to another script, or executable as a parameter, which will execute the script and then prompts the user to press a key.
e.g.
scriptwrapper:
Bash:
#!/usr/bin/env bash
# show an error message and exit
die()
{
echo -e "ERROR: $1\n"
echo -e "Usage: scriptwrapper /full/path/to/executable/\n"
exit 1
}
# Ensure we have one parameter
if [ $# -ne 1 ]; then
die "Incorrect number of parameters!"
fi
# Ensure the parameter is an executable file
if [ ! -x "$1" ]; then
die "$1 is not an executable!"
fi
# Run the executable and then prompt the user to press a key
"$1"
read -p "Press any key to continue..." -n1 -s
echo
Save that as
scriptwrapper
and make it executable with
chmod +x ./scriptwrapper
.
Copy that to
/usr/local/bin
(as root) alongside your other scripts - then you can use scriptwrapper to run your scripts in your .desktop files.
e.g.
In your .desktop file for each of your scripts:
Code:
Exec=/usr/local/bin/scriptwrapper /usr/local/bin/yourscript
Terminal=true
scriptwrapper requires the FULL path to your script/executable.
That way, when the icon is clicked in the menu, the .desktop file will open the systems default terminal and run the scriptwrapper script, passing your script as an argument. Then scriptwrapper will run your script. After your script has finished, the wrapper script will prompt the user to "press any key to continue..." - which will cause the terminal window to close when the user presses a key.
That might be a more elegant solution to the problem. That way you can run your scripts directly in the terminal with no annoying "Press any key" prompt. But if you run your scripts via your desktop menu/launcher - it will run it through the wrapper and display the "Press any key" prompt to prevent the terminal from disappearing too quickly.
That might be a better solution.
So the original problem had nothing to do with permissions as suggested by the others, it was simply a syntax error in the .desktop file, due to a brain-fart that I had. Completely my fault! Hopefully the scriptwrapper script I wrote makes up for my mistake! Ha ha.
BTW - DON'T make a .desktop file for the scriptwrapper script, just use the scriptwrapper script in the .desktop files that run your scripts.
I hope that all made sense?!....