8

Lets suppose that there are two binary files, e.g. XXX and YYY, at destination /usr/bin/. I want to start them at once, always! In other words, when I type the name of either of those in unity, I want to make both of them start. How could I change the corresponding files at destination /home/username/.local/applications/ to do so? I tried this /usr/bin/XXX;/usr/bin/YYY; on terminal but it doesn't seem to work.

efthialex
  • 3,941
user88349
  • 309

4 Answers4

9

As I understand you need to edit your .desktop file. Add this line next to Exec:

sh -c "/usr/bin/XXX & /usr/bin/YYY"

The -c flag tells to the shell that it has to read the commands from string, instead of from the standard input.


If you use only /usr/bin/XXX & /usr/bin/YYY it won't work. Just to add the reason why & doesn't work in a launcher, it's because & is a feature of the shell, and the launcher isn't a shell, its a much simpler environment for running commands.

efthialex
  • 3,941
2
/usr/bin/app_first & 
/usr/bin/app_second

Using '&' you are sending process into background.

bluszcz
  • 212
1

You should use

/usr/bin/XXX && /usr/bin/YYY;

Note the use of && (no need to use & to run something in the background).

don.joey
  • 29,392
0

You will need to add the command names XXX and YYY into a directory at an earlier point in the search path. For both this command named file will run the original XXX and YYY by using the full path names /usr/bin/XXX and /usr/bin/YYY. This is to prevent the script from re-running itself forever in a loop (or until your computer runs out of memory). An alternative to this is replacing the commands with your script and moving the original commands to another path like /usr/local/bin.

This script needs to run both /usr/bin/XXX and /usr/bin/YYY in the background so they are running at the same time. The classic way to do this is:

/usr/bin/XXX &
/usr/bin/YYY

As described by bluszcz above. You might also want to put the " &" on the 2nd command as well. An alternative way to more quietly put these commands in the background is with screen, which could be coded in the script like this:

screen -dmS XXX /usr/bin/XXX
screen -dmS YYY /usr/bin/YYY

That can have the advantage in cases where you might want to go see the progress of the commands without doing logging, bu using screen to attach to the sessions that creates.

Skaperen
  • 435