1

I made two shell (.sh) script files, audio.sh and video.sh for my Pi CCTV project.

And I combined those two scripts:

sh -x video.sh & sh -x audio.sh &

I put the command above into a shell file and finally made the test.sh file, which now lanuches the two shell files simultaneously.

However, I'm not satisfied that I should run the command: sudo ./test.sh. I would like to make an executable file (double-click and launch) which can launch test.sh.

There is a YouTube video demonstrating that it's possible to make an Apple script in Mac OS (linking the two files, compile and execute) and export it by an executable program (.app format). If the program is launched, the two shell scripts are launched together in two Terminal window(s), as you see in the video : https://www.youtube.com/watch?v=hkY4_qYWfqI

Is it possible to do such a thing like that in Ubuntu 16.04?

Making a program that executes the two shell scripts simultaneously?

Any ideas?

Felix Lee
  • 143

1 Answers1

3

A .desktop file will provide what you want.

Create the following file, with a filename like ANYTHING.desktop:

[Desktop Entry]
Encoding=UTF-8
Exec=gksudo /MAKE/THIS/THE/PATH/TO/test.sh
Path=/MAKE/THIS/THE/PATH/TO/THE/OTHER/FILES
Type=Application
Terminal=true
Name=Pi CCTV project
Categories=AudioVideo;

Save it wherever you want, e.g. in ~/Desktop, and it will run when you click on it.

Alternatively, save it in ~/.local/share/applications if you want it to appear in your menu.

This runs test.sh with gksudo instead of sudo, to give you a graphical password dialog.

In test.sh add a wait to the end as so:

sh -x video.sh & sh -x audio.sh & wait

This is needed so the window won't close until both programs are finished.

If you really want two windows, change test.sh to:

xterm -e sh -x video.sh & xterm -e sh -x audio.sh & wait

and change Terminal=true to false in the .desktop file.

Martin Thornton
  • 5,996
  • 12
  • 32
  • 43