I want to launch a bash script from a lxde desktop shortcut. e.g
[Desktop Entry]
Encoding=UTF-8
Name=Test
Comment=Test launch script
#Exec=sh /home/chris/mytest.sh
Exec=lxterminal --working-directory=/home/chris -e "sh mytest.sh"
Terminal=false
Type=Application
StartupNotify=true
-rwxr-xr-x 1 chris chris 34 Feb 15 09:42 mytest.sh
But my simple test does not work with either of the "exec" lines above. In the case of the "Exec=lxterminal..", a terminal just flashes briefly on screen. While the "Exec=sh ..." does nothing.
What is the correct way to do this?
did you already try terminal=true ?
Yes. If I use "Exec=sh ..." I set "Terminal=true", which seemed logical but either way the simple test scipt is not executed.
I don't know if lxterminal has a "hold" function...?
Alternative: xterm
Exec=xterm -hold -e 'your command'
Edit:
Exec=lxterminal --command='bash -c "your command"'
Clearly I need to learn more about terminals, shells etc.
Your ref to "xterm -hold" made me realise my "Exec=lxterminal.." line was just creating a window that destroyed itself without visible output.
In fact it's worse than that, if I use your second example and the command was just a simple "ls -l" then the lxterminal window just flashes on screen. But, if the Exec line in the desktop file is for example:
Exec=lxterminal --working-directory=/home/chris/ -e "./mytest"
and mytest is:
#!/bin/bash
ls -l
echo " "
read -s -r -p "Press any key to exit... " -n 1
echo ""
You finally get an Lxterminal with output that only destroys itself after a key press.
My big mistake was I thought the lxterminal man pages meant you could open a lxterminal at a given working directory, automatically run a command/script with the usual shell prompt. It doesn't work that way.
Quote from: "krisbee"if I use your second example and the command was just a simple "ls -l" then the lxterminal window just flashes on screen.
Ok, I'd tested it with "/usr/bin/htop" as command and that worked with the "command bash" combination (not without the bash -c addition and not without command=), the lxterminal window stayed open. When I use "ls -l" as you said, it does not... The latter only works as
Exec=lxterminal --commmand='bash -c "ls -l && read -p \"\""'Lxterminal is a fast but rather basic terminal client...
Glad to see you found a solution.