Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Simple program selection menu using Bash
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Blood_Roses75
n00b
n00b


Joined: 10 Jun 2004
Posts: 13
Location: Michigan

PostPosted: Sat Oct 02, 2004 5:24 am    Post subject: Simple program selection menu using Bash Reply with quote

Hey, here's a simple program I wrote using bash so that I can easily run whichever program I want without having to memorize it's name or configure it for each window manager I have. The menu was originally started for running games, so I had put it in /usr/games/bin for simplicity.

first i did a 'nano /usr/games/bin/gamemenu'. I then added this script:

#!/bin/bash
let "loop=0"
while test $loop == 0
do
clear
echo "Please choose the letter of the game you want to run and enter"
echo "--------------------------------------------------------------"
echo "a. Neverwinter Nights o. Rise Of The Triad"
echo "b. Abuse p. OpenMortal"
echo "c. Quake 3 r. Glaxium"
echo "d. Unreal Tournament s. Spacearyarya-KXL"
echo "e. The Ur-Quan Masters t. Beneath A Steel Sky"
echo "f. Tuxracer u. Epiar"
echo "g. Frozen Bubble v. Pydance"
echo "h. Civilization- Call To Power w. Globulation 2"
echo "i. Xbill x. OpenGladiator"
echo "j. Geki2-KXL y. Foobillard"
echo "k. Geki3-KXL z. Phobia II"
echo "l. T.O.R.C.S."
echo "m. Lgeneral"
echo "n. Chromium"
echo "--------------------------------------------------------------"
echo "q. quit"
echo "choice?"
read choice

case $choice in q)
let "loop=1"
esac
case $choice in a)
echo "you are running Neverwinter Nights"
cd /opt/nwn
./nwn
cd /usr/games/bin
esac
case $choice in b)
echo "you are running Abuse"
/usr/games/bin/abuse.sdl -fullscreen
esac
case $choice in c)
echo "you are running Quake 3"
/usr/games/bin/quake3
esac
case $choice in d)
echo "you are running Unreal Tournament"
/usr/games/bin/ut
esac
case $choice in e)
echo "you are running The Ur-Quan Masters"
/usr/games/bin/uqm -f -o
esac
case $choice in f)
echo "you are running tuxracer"
/usr/games/bin/tuxracer
esac
case $choice in g)
echo "you are running frozen bubble"
/usr/bin/frozen-bubble
esac
case $choice in h)
echo "you are running civilization-CTP"
/usr/local/games/CivCTP/civctp &
esac
case $choice in i)
echo "you are running xbill"
/usr/games/bin/xbill &
esac
case $choice in j)
echo "you are running geki2-KXL"
/usr/games/bin/geki2 &
esac
case $choice in k)
echo "you are running geki3-KXL"
/usr/games/bin/geki3 &
esac
case $choice in l)
echo "you are running torcs"
/usr/games/bin/torcs &
esac
case $choice in m)
echo "you are running lgeneral"
/usr/games/bin/lgeneral
esac
case $choice in n)
echo "you are running chromium"
/usr/games/bin/chromium &
esac
case $choice in o)
echo "you are running rott"
/usr/games/bin/rott &
esac
case $choice in p)
echo "you are running openmortal"
/usr/games/bin/openmortal &
esac
case $choice in r)
echo "you are running glaxium"
/usr/games/bin/glaxium &
esac
case $choice in s)
echo "you are running spacearyarya-kxl"
/usr/games/bin/spacearyarya &
esac
case $choice in t)
echo "you are running beneath a steel sky"
/usr/games/bin/bass &
esac
case $choice in u)
echo "you are running epiar"
/usr/games/bin/epiar &
esac
case $choice in v)
echo "you are running pydance"
/usr/games/bin/pydance &
esac
case $choice in w)
echo "you are running globulation2"
/usr/games/bin/glob2 &
esac
case $choice in x)
echo "you are running OpenGladiator"
/usr/games/bin/openglad &
esac
case $choice in y)
echo "you are running foobillard"
/usr/games/bin/foobillard &
esac
case $choice in z)
echo "you are running phobiaii"
/usr/games/bin/phobiaII &
esac
done


This menu is easily adjusted to your preferences, does not need to be compiled each time, and fits on the terminal screen in one page. Later I decided to setup menus for other programs like internet related stuff. Finally I created a menu that calls the other menus as needed called menuprog:

#!/bin/bash
let "loop=0"
while test $loop == 0
do
clear
echo "Please choose the letter of the menu you want to go to"
echo "--------------------------------------------------------------"
echo "a. Games"
echo "b. Emulators"
echo "c. Multimedia"
echo "d. Internet"
echo "e. Editors"
echo "f. Misc"
echo "--------------------------------------------------------------"
echo "q. quit"
echo "choice?"
read choice

case $choice in q)
let "loop=1"
esac
case $choice in a)
echo "entering games menu"
cd /usr/games/bin
./gamemenu
esac
case $choice in b)
echo "entering emulators menu"
cd /usr/games/bin
./emumenu
esac
case $choice in c)
echo "entering multimedia menu"
cd /usr/games/bin
./mediamenu
esac
case $choice in d)
echo "entering internet menu"
cd /usr/games/bin
./netmenu
esac
case $choice in e)
echo "entering editors menu"
cd /usr/games/bin
./editmenu
esac
case $choice in f)
echo "entering miscelaneous menu"
cd /usr/games/bin
./miscmenu
esac

done


Once these menus are created, you need to do a chmod 777 on each file to make it excuteable and useable by any account.

To run the menu, all you have to do is call the name of it inside a terminal window. Ex: './menuprog'. Now when you are in the menu, all you have to do is select the letter of the program and hit ENTER, or q and ENTER to leave the menu or program.
:D

I hope this is of some use to people since it has definitely made it easier for me to remember all the programs I have installed and to run them.
Back to top
View user's profile Send private message
nbkolchin
Apprentice
Apprentice


Joined: 07 Feb 2004
Posts: 290
Location: Russia, Saint-Petersburg

PostPosted: Sat Oct 16, 2004 9:04 pm    Post subject: Reply with quote

Err. Ever heard about dialog? Just man dialog

Nickolay
Back to top
View user's profile Send private message
Blood_Roses75
n00b
n00b


Joined: 10 Jun 2004
Posts: 13
Location: Michigan

PostPosted: Thu Nov 18, 2004 4:33 am    Post subject: Reply with quote

Umm... actually, no I haven't before you mentioned it.... actually had to go to it's homepage to recognize it at http://hightek.org/dialog/. I've just seen the results it produces and didn't know what program was used to create its output. Usually I just strictly code in C/C++ with SDL libraries for sound and graphics.

It may be something I may want to try later to spice up the menus I run...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum