Create a Launcher in Ubuntu Using Bash
"Hi Oltjano! How are you? Can you help me to create an executable file in Ubuntu? I want it to start my lamp server, I want to save time and I don't like to type long commands in my terminal."
This was a message from my friend that is learning web development in his Ubuntu laptop. Time is priceless and finding a new easy way to get the job done is one of my priorities. I have some experience with Bash scripting so I decided to help my friend with a simple Bash script that starts up his LAMP server. The script is very easy to write and understand even for a newbie, but the idea is to tell you how important and powerful is shell scripting, in our case Bash.
You can do magic with a few lines of code and automate repetitive tasks that take your irreplaceable time everyday. My friend knew how to start the LAMP server from terminal with the ‘/opt/lampp/lampp start‘ command, but he wanted an executable file in desktop to click, so every time he wants to start the server he double clicks that file and the server starts. This was easy for me, because I know how to create a file with .desktop extension, a file that is used to launch a specific application.
I created a Bash script like shown in Figure 1 and started thinking about the file launcher. The first line of the Bash script shown below is the shebang line, which tells the system what interpreter to use, the second line assigns the variable start to our command and the third line echoes the result of the ‘/opt/lampp/lampp start’ command when it is executed.
Before creating the launcher we should make our bash script executable with chmod u+x command, like shown in Figure 2.
We need an icon for our launcher so I downloaded one image from Google Images. What do you do next? Open your favorite text editor and copy paste the code below:
[Desktop Entry] Version=x.y Name=ProgramName Comment=This is my comment Exec=/home/alex/Documents/exec.sh Icon=/home/alex/Pictures/icon.png Terminal=false Type=Application Categories=Utility;Application;
I think this piece of code is self explanatory, but it deserves a simple explanation:
- Version: The version of the .desktop file
- Name: The name of the application. You can put the name you like here.
- Comment: The comments is used to describe your program. What is the purpose of your program?
- Exec: Put the path of the file you want the launcher to execute. For example, /home/oltjano/Desktop/:p.sh
- Icon: Icon of your launcher. Put the path of the image you want to use for the icon.
- Terminal: This line is used to specify if the application should run in a terminal window or not
Now we specify the path of the file we want to execute and the path of the icon for our file, like shown in Figure 3 and in Figure 4.
The file I want to execute is server.sh and I will use SL383952.jpg as an icon for the launcher. Save this file with aname.desktop and change its permissions to executable , like shown in Figure 5.
You can specify the version of the desktop file as well but it is not necessary. You can create your own bash scripts for your specific tasks and use them.
This article was a short introduction to desktop files and how to create them in order to make your life easier. This a simple example that shows the basics of creating a launcher, but I think it is enough for a good start.
Like us on Facebook
We need your assistance to stay live
This week Top Posts
- Top Things To Do After Installing Ubuntu 13.10 'Saucy Salamander' : Ubuntu 13.10 Saucy Salamander will be released on coming October 17th with many new salient featur...0 comments |
- Install Fail2Ban On Ubuntu Server 13.04/13.10 : Introduction Fail2Ban is an intrusion prevention framework written in the Python programming l...0 comments |
- 5 Android Apps that’s Going to Make Running Your Business Less Stressful : Running a business can be very stressful. You have to think about team collaboration, making sure th...0 comments |
- install Git in Ubuntu : Git is a distributed revision control system with an emphasis on speed. Git was initially designed a...0 comments |
- Install Crashplan backup tool in Linux : CashPlan is an automated backup solution that either uses the CrashPlan Central server or any other ...0 comments |
- Install Corosync and Pacemaker On CentOS 6.5 : I will show you in this tutorial how to install your first cluster Corosync and the Linux Cluster Ma...0 comments |
- Install Uget Download Manager In Ubuntu, Fedora, Debian
- Download Elementary OS ‘Luna’ Official Wallpapers
- Install Power Commands 0.1.5 On Ubuntu 14.04/13.10/12.10/12.04
- 5 Android Apps that’s Going to Make Running Your Business Less Stressful
- Puppet agent Install Using Script
- Install Corosync and Pacemaker On CentOS 6.5
- Install Fail2Ban On Ubuntu Server 13.04/13.10
- How To Install Google Chrome in Fedora 20, 19, 18
- How to surf using Tor Browser Bundle
- New Games got Greenlit on Linux by Steam Today!
This work by unixmen.com is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
Copyright © 2008-2013 Unixmen.com .