PDA

View Full Version : help with menu script



bob58
11-27-2004, 03:51 AM
I need help making a simple MENU which contains choices of 5 streaming audio websites to play via MPLAYER using the KONSOLE.

I have a sub-directory in /home called "streamscripts" which contains 5 script files. They are "cbc.sh" "rock.sh", "rock2.sh", "jazz.sh", and "jazz2.sh".

I bring up konsole, type in, for example "./ jazz.sh" and mplayer starts and goes to the URL for that particular jazz music stream. It loads and then plays. I quit by typing a "Q"......

I would like a very simple menu, similar to this:

"What would you like to hear?"
------------------------------------
jazz
jazz2
rock
rock2
cbc
-----------------------------------

And thats about as far as I can figure.....how do I call the chosen script from the "streamscripts" directory? If I chose "jazz" for example, how do I associate the menu choice to the actual script file? I can do this in DOS easily but do not know how to do it in LINUX!
Please help! bob

shah
11-27-2004, 04:38 AM
Refer to your last post. I already show you how to create script to invoke xmms.


I have a sub-directory in /home called "streamscripts" which contains 5 script files. They are "cbc.sh" "rock.sh", "rock2.sh", "jazz.sh", and "jazz2.sh".

You don't have to put that .sh extension. If you do put it, you only able to run it from konsole. You only need to name it as cbc, rock, jazz and jazz2; and make that file executable.
If you do this way, you can easily create a menu and submenu using menu editor.
ex:

#!/bin/sh
xmms http://aud-one.kpfa.org:8090/kpfa.ogg
save that file as music in your home/streamscript/.
Right click on that file----->properties------->permission-->tick executable.

Better use xmms because that script will open xmms.
If you use mplayer, it will run in background and you will have dificulty to quit mplayer unless you use kill command.

Then open menu editing tools and create your own menu with all the submenu you want....you can even set it to run in tray.

:D :D

firebyrd10
11-27-2004, 04:42 AM
I think he wants a script that will hsow a menu of the options, then start what he wants to hear.

firebyrd10
11-27-2004, 05:39 AM
I don't have a script, but this little C program should do the trick.



#include <stdio.h>

main()
{
int pick;
system("clear");
while(1)
{
pick=0;
printf("\"What would you like to hear?\"\n");
printf("------------------------------------\n");
printf("1 - jazz\n");
printf("2 - jazz2\n");
printf("3 - rock\n");
printf("4 - rock2\n");
printf("5 - cbc\n");
printf("6 - quit\n");
printf("------------------------------------\n");
scanf("%d",&pick);
switch(pick)
{
case 1:
system("xmms http://jazz adress");
exit(1);
break;
case 2:
system("xmms http://jazz2 adress");
exit(1);
break;
case 3:
system("xmms http://rock adress");
exit(1);
break;
case 4:
system("xmms http://rock2 adress");
exit(1);
break;
case 5:
system("xmms http://cbc adress");
exit(1);
break;
case 6:
exit(1);
break;
default:
printf("Enter a choice from above.\n\n\n");
sleep(1);
exit(1);
}
}
return(0);
}


Save it as music.c and then change the xmms http://something adress to whatever command you use to open up the music in your scripts. Or you could change it to your scripts. ex: /home/user/jazz.sh


Then save and type

cc music.c in the same directory as the file.

You'll probably get something called a.out Change the name to you suiting.

Then just open a terminal and type the name.

(Anyone know how to just click on it to make it work?)

bob58
11-27-2004, 05:49 AM
WOAH!!!! I will try to attempt to do what firebird and shah suggested.....looks pretty deep to me, but I will give it a shot. I will use xmms instead of mplayer....good idea. and i thought a script file had to have the "sh" extension to work? I can make the files executable without the "sh" extension? OK I will try that......I will post back in couple days to let you know how I did...thank you for good ideas...bob

firebyrd10
11-27-2004, 05:52 AM
WOAH!!!! I will try to attempt to do what firebird and shah suggested.....looks pretty deep to me, but I will give it a shot. I will use xmms instead of mplayer....good idea. and i thought a script file had to have the "sh" extension to work? I can make the files executable without the "sh" extension? OK I will try that......I will post back in couple days to let you know how I did...thank you for good ideas...bob

Yea, its more complicated then it looks, most of the stuff can be figured out even if you don't know C though.

bob58
11-27-2004, 06:33 AM
OK I tried what Firebird suggested but it would not work.....I did as you suggested, saved the file as music.c and saved it in the same directory as my script files.....i typed cc music.c and the response i get is: music.c:1: include file 'stdio.h' not found. There is a reference to 'stdio.h' at top of file.

Then I did it again and it came back: bash: music.c: command not found

I entered in the URL's of each of the streaming audio sites like you said.....in the file you sent.

So maybe i did something wrong? bob

firebyrd10
11-27-2004, 06:35 AM
Very weird, knoppix should include the header files.
What version are you useing.

shah
11-27-2004, 09:11 AM
I did try firebird10 C code and it works.
It will create a.out executable.
Create an application link to this file on desktop and in advanced tab, tick run in terminal. This way you can just click.
The problem is, when you close the konsole, xmms will close too, vice versa..

Bob...can you share the link? The first one is very nice.... :D :D

bob58
11-29-2004, 12:52 PM
I am using KNOPPIX version 3.7

I don't understand why that program wouldnt run. Maybe 3.7 has a problem with it. I can try it again tonite when i get home from work. I do have version 3.4 on my desktop....maybe i will try to run the C program on that computer. I will post back later with results....thanks for the help :D ...bob

firebyrd10
11-29-2004, 11:53 PM
I am using KNOPPIX version 3.7

I don't understand why that program wouldnt run. Maybe 3.7 has a problem with it. I can try it again tonite when i get home from work. I do have version 3.4 on my desktop....maybe i will try to run the C program on that computer. I will post back later with results....thanks for the help :D ...bob

Your welcome, I compiled it with 3.6 but you can compile iwth 3.4 also.