Ubuntu desktop icon to launch scripts
If you would like to launch a script, or a collection of scripts from a desktop icon on ubuntu.
from ~/Desktop create a file with the extension of .desktop in my case I made start.desktop
[Desktop Entry] Name=Start Comment=Lorem Script Exec=/home/jon/Development/my-project/start.sh Terminal=false Type=Application Icon=/home/jon/Development/my-project/icon.svg
For more options you can check them out here
Now that we have that running, this will run the start script on when it opens. If you wish to see terminal output you can change Terminal=true. One thing I noticed is that if you wish to have a script running and stay open, make sure that not all of the scripts end with the & command to put them in the background. In my case I ran a script that was an angular application with a chromium browser opening up ( to be a kiosk ). I had to make sure that the chromium browser was a script that didn’t exit in order for it to work.
#!/bin/sh # run kiosk /home/jon/.nvm/versions/node/v9.4.0/bin/node /home/jon/Development/my-project/client.js & sleep 10 # run web server /home/jon/.nvm/versions/node/v9.4.0/bin/npm start --prefix /home/jon/Development/my-project/app & sleep 15 chromium-browser http://localhost:8080 --kiosk
The sleeps in this context will make sure that it is running properly and the chromium-browser does not run without giving an ample amount of time for the npm start to finish. Make sure to check your applications you wish to run ( node, npm ) with which node to figure out the proper running path directory to make sure it works as intended if you wish to run it as a different user.