LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 07-28-2012, 08:55 PM   #1
p3aul
Member
 
Registered: Jul 2011
Distribution: Ubuntu 10.04
Posts: 116

Rep: Reputation: Disabled
convert a Perl script that runs in the terminal to a launcher


I would like to place the launcher in the applications menu or on my top panel(Gnome 2 desktop) How would I do this?
Thanks
Paul
 
Old 07-28-2012, 10:33 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,345

Rep: Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565
just wright a custom " ProgramName.desktop " file
in /usr/share/applications
--- example desktop file
Code:
[Desktop Entry]
Name=WordWarVi
GenericName=wordwarvi

Comment=Scrolling space shooter
Exec=wordwarvi --sounddevice 0
Icon=/DATA/SUSE12/share/wordwarvi/icons/wordwarvi_icon_128x128.png
Terminal=false
Type=Application
Categories=Game;ArcadeGame;
StartupNotify=false
use the existing files as a guide

if it is executable by just double clicking on it it will run from a *.desktop file

however on very rare occasions you might need to write a tiny bash launcher
and point the *.desktop file to that

an example ( not perl but c++ )
it the qt4 svn build of the program Celestia using a "splash image " on start up
(bug work around so...)

i need to have the *.desktop file point to a tiny shell script
Code:
 #!/bin/sh

cd /DATA/SUSE12/bin/
 ./QT4celestia-svn

Last edited by John VV; 07-28-2012 at 10:40 PM.
 
Old 07-28-2012, 10:47 PM   #3
p3aul
Member
 
Registered: Jul 2011
Distribution: Ubuntu 10.04
Posts: 116

Original Poster
Rep: Reputation: Disabled
Right now I have to type at the command line; perl temp.pl it won't run as a stand-alone file. What would be the bash command to execute perl with temp.pl as the argument?.
If I put it in /usr/share/applications would it automatically appear under the applications menu? That probably a dumb question. Why else would the subfolder be named "Applications"!

I used to know how to create a launcher. Could you refresh my memory?
Thanks,
Paul
 
Old 07-28-2012, 11:21 PM   #4
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,345

Rep: Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565Reputation: 2565
the location in the gnome2 menu will depend on what is defined in the *.desktop file
the WW-Vi game is set for
" Categories=Game;ArcadeGame; "

under the gnome2 menu it will be under games

and under KDE there IS a "ArcadeGame" sub menu


but
you could use the already built in GUI tool

just edit the gnome menu
r-click it and add a new program
 
Old 07-28-2012, 11:45 PM   #5
p3aul
Member
 
Registered: Jul 2011
Distribution: Ubuntu 10.04
Posts: 116

Original Poster
Rep: Reputation: Disabled
John, I found a site that explained how to create and add a launcher. since I have to type "perl temp.pl I decided to create a shell script that would execute the perl interpreter with my script "temp.pl" as the argument like this:
Code:
#!user/bin/sh
perl perl.pl
I have the shell script and the perl script saved to the same dir. I then went to System=> Main Menu. selected the Science folder under applications and pressed the + button to add the shell script to it. I selected "Application in Terminal" and browsed to the folder where both scripts were. This put the launcher where I wanted it but when I clicked on the launcher in the "Science" dir, nothing happened. I know the shell works because I tested it. What is wrong?
Thanks
 
Old 07-29-2012, 01:05 AM   #6
fogpipe
Member
 
Registered: Mar 2011
Distribution: Slackware 64 -current,
Posts: 550

Rep: Reputation: 194Reputation: 194
For the launcher exec command use something like
Code:
xterm -e PATHTOPERLPROGRAM
IIRC this will close the term immediately on completion of the script.

Last edited by fogpipe; 07-29-2012 at 01:07 AM.
 
Old 07-29-2012, 02:02 AM   #7
p3aul
Member
 
Registered: Jul 2011
Distribution: Ubuntu 10.04
Posts: 116

Original Poster
Rep: Reputation: Disabled
Thanks, I found my problem. I just had to cd to the dir that I had placed both scripts in. I also put a read command in the shell script to keep it open but found trhat wasn't necessary. Everything works find now. I have now converted some other shell scripts to launchers via that method.
Thanks to all,
Paul
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script, Perl script, command or utility to convert Binary to text Perseus Programming 26 07-12-2012 06:00 AM
Perl script runs in terminal but not when called by nagios nicko18 Linux - Software 1 04-11-2012 11:37 AM
Desktop Launcher of shell-script in gnome-terminal skipidar Linux - Newbie 1 06-24-2009 09:27 AM
gnome-terminal launcher script Mur Linux - Software 0 04-26-2004 10:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 08:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration