Consider this script (saved as /home/muru/test.sh
):
#! /bin/bash
DRI_PRIME=1 glxgears -info
A basic launcher for this would look like (say, save it as /home/muru/test.desktop
):
[Desktop Entry]
Type=Application
Terminal=true
Name=glx-gears-info
Exec=/home/muru/test.sh
Make them both executable:
chmod +x test.sh test.desktop
Now you should have these two entries in your home folder:
Notice how the name is glx-gears-info
even though the launcher's filename is test.desktop
. You can double click on it to start the script:
For a script like (say, located at /home/muru/start-aria.sh
):
#!/bin/bash
touch /home/cip/Downloads/aria2/session.txt && \
aria2c --enable-rpc --rpc-listen-all \
--save-session=/home/cip/Downloads/aria2/session.txt \
--input-file=/home/cip/Downloads/aria2/session.txt -x16 -s16 -k1M \
--dir=/home/cip/Downloads/aria2
(I split the command into multiple lines for readability) the launcher file would look like (say /home/muru/start-aria.desktop
):
[Desktop Entry]
Type=Application
Terminal=false
Name=Start Aria2
Exec=/home/muru/start-aria.sh
You can set Terminal=false
here as this command probably doesn't need a terminal.
To get the terminal window when using Xfce launchers, tick 'Run in Terminal'.
A second command, that would close aria2, can be added in the same Xfce launcher: pkill aria2c
Also:
(namely 'show last used item' and 'inside button'),
- and adding two specific icons,
the launcher will always display the current status of aria2: running or closed.
Try this:
while true; do xterm && break; done
Applications have exit status codes so that if something exits fine it returns zero... And if something went wrong, it throws out another number. This allows people to hook in and find out the exact issue. This is what the other answer is doing.
&&
just checks that the previous command was a zero-status exit and if it was, breaks the loop. If it crashes, it'll throw out something other than 0 and the && ...
clause won't trigger; it'll simply loop back around and run xterm
.
Best Answer
The solution is to simply use the right form in the pipe:
This works both from terminal and from a desktop launcher. No need to use nohup.