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/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.

 

/home/jon/Development/my-project/start.sh

#!/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.

Jon

Innovative, entrepreneurial and positively unsatisfied mind that constantly pushes the tech boundaries to create new solutions and devices that change people’s lives. Throughout my career, I have had the opportunity of having a multi-disciplinary experience, which led me to wear the hats of: Architect, IoT Consultant (Internet of Things Consultant), Developer, Designer, Engineer, Server Admin, Consultant and Project Manager – to name a few. Based on this diversified background, I get projects done by following smart ideas and well-planned goals. In a world which is getting more unconventional by the day, I use unconventional ways, and a very healthy dose of integrity, to create devices and solutions that help companies go from a steady present to a dynamic future.

You may also like...