LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   how can I create dual application launcher (https://www.linuxquestions.org/questions/linux-software-2/how-can-i-create-dual-application-launcher-637087/)

ameyjah 04-22-2008 02:36 PM

how can I create dual application launcher
 
May be the title is bit confusing...

I want to create one application launcher (one small program) which will do the following things.

1) On first click(execution) it should execute following command
sudo pon dsl-provider
2) If I once again execute the same file it should execute following command
sudo poff

Can you tell me how to create one such application

rg.viza 04-22-2008 02:57 PM

make a script that looks for the existence of the pid (or greps ps output) and test the output of the grep.

If the first isn't running start sudo pon dsl-provider >>/dev/null 2>&1 & and exit.
If the first is running but not the second, start sudo poff >>/dev/null 2>&1 & and exit.
If both are running just exit.

It would be useful if you had return messages as well so the user who uses it knows what it did or didn't do.

The gory details of how to code this are a lesson in shell/perl/python/qt (or whatever you choose to use) coding 8)

biophysics 04-22-2008 03:20 PM

Code:

#!/bin/bash

if [ -e /tmp/dsl_running ]; then
      sudo poff >>/dev/null 2>&1 &
      rm -f /tmp/dsl_running
else
      sudo pon dsl-provider >>/dev/null 2>&1 &
      touch /tmp/dsl_running
fi


ameyjah 04-22-2008 09:47 PM

Quote:

Originally Posted by biophysics (Post 3129386)
Code:

#!/bin/bash

if [ -e /tmp/dsl_running ]; then
      sudo poff >>/dev/null 2>&1 &
      rm -f /tmp/dsl_running
else
      sudo pon dsl-provider >>/dev/null 2>&1 &
      touch /tmp/dsl_running
fi


hey can someone compile me the above code or give direction to use above code

biophysics 04-23-2008 06:12 AM

1. Create a directory called bin in your home folder (normally there might be one)
$ mkdir ~/bin

2. Create a file inside this with
gedit or kwrite or any editor

$ gedit dsl_controller

paste the stuff from above.

3. Type:

$ chmod +x ~/bin/dsl_controller

4. Now, right click on desktop

>>>>>>>>>Select: Create new link to application /launcher

The above may be different in gnome (I have only kde) http://ubuntuforums.org/showthread.php?t=361110
http://www.linuxquestions.org/questi...script-283613/
5. It will open a new box

6. Select there the program you created > "dsl_controller"

7. Press OK


All times are GMT -5. The time now is 02:34 PM.