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
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 |
- Manage Databases And Hosted Servers Remotely With DbNinja : Database administration via command line is bit difficult for newbie system and database administrat...0 comments |
- Setup IT And Asset Management System With GLPI On Debian/Ubuntu : GLPI is the Information Resource-Manager with an additional Administration Interface. You can use it...0 comments |
- How To Configure Linux Clients To Authenticate Using OpenLDAP : This is the continuation of our previous tutorial. In our previous tutorial we learned how to instal...0 comments |
- Install FrostWire 5.6.9 In Elementary OS 'Luna'/ Ubuntu / Linux Mint : FrostWire is a peer-to-peer file sharing program for the gnutella and BitTorrent protocols. FrostWir...0 comments |
- How To Upgrade From Ubuntu 13.04 Raring To Ubuntu 13.10 Saucy Salamander : Ubuntu 13.10 Saucy will be released on October 17th. Hope it will come with lot of improvements and ...0 comments |
- How To Install Linux Kernel 3.12.4 In Ubuntu
- Firefox 26 Has Been Released, How To Install It In Ubuntu And Its Derivates
- How To Install Brasero In Elementary OS ‘Luna’
- Install Sayonara Player In Elementary OS / Ubuntu / Linux Mint
- Manage Databases And Hosted Servers Remotely With DbNinja
- Install FrostWire 5.6.9 In Elementary OS ‘Luna’/ Ubuntu / Linux Mint
- Setup IT And Asset Management System With GLPI On Debian/Ubuntu
- How To Configure Linux Clients To Authenticate Using OpenLDAP
- How To Install Netflix In Ubuntu
- cowsay And fortune Combined Together
This work by unixmen.com is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
Copyright © 2008-2013 Unixmen.com .