I want the same launcher shortcut to act like a ON/OFF switch.
For example, suppose I have made a launcher to start LAMPP with the command:
gksudo /opt/lampp/lampp start
This works properly to start LAMPP. Now, what I want to do is:
If LAMPP is not on, the launcher should execute the above command and start LAMPP.
If LAMPP is on, I want to to execute the command
gksudo /opt/lampp/lampp stop
and stop lampp.
I want these two commands to be executed by the same launcher where the command to be executed is decided on the basis of a condition (LAMPP being ON or OFF in the above example).
Can I do this? And how?
I guess writing a bash script and then making the launcher execute the bash script would do it. But then how do I check whether LAMPP is on of off?
I noticed that lampp starts
proftpd
so we can modify a scirpt that checks for a running service, if that service is running then it will stop lampp, I modified the script from here - http://www.anyexample.com/linux_bsd/bash/check_if_program_is_running_with_bash_shell_script.xmlSo first make an empty text file, or open gedit, and paste this code-
This should also send notification that it starts and stops.
Save the file as
lampp.sh
and make it executable - right click => Properties => Permissions => Allow executing file as program.Now use your favorite method to make a launcher with the script, How can I create launchers on my desktop?
Or I made one that includes the icon-
Place
lampp.sh
in/usr/local/bin
Create a file named
Lampp.desktop
and paste this into it-Or if you want you can make a right click list for the different functions to achieve start and stop function without the script-
So use one or the other, have fun.
Also I found they wrote a control panel for the program to use-
I you want to try this with other programs you can make scripts that will check if the are running and will kill them (warning might loose work, but would be nice for frozen programs) Say for example
conky
or any other program, mostly.save as conky.sh put in
/usr/local/bin
Next is the hard part, you need to find the conky.desktop file, so in terminal type
locate conky.desktop
then navigate to that folder and edit the desktop file in gedit (or your favorite editor, may need privileges depending on where it is) and replace theExec=
line withExec=/usr/local/bin/conky.sh
(note that this will break any of the launchers that have right click menus)