LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 07-10-2008, 09:12 PM   #1
Anithen
Member
 
Registered: Aug 2003
Location: Florida
Distribution: Slackware 12, Slackware 12.1, Slackware 12.2
Posts: 105

Rep: Reputation: 15
Question A way to open a window for user input in shell script?


Is there a way to have a script open a window for user input? The only way I can do this now is like: ... from an example from my script:
/usr/bin/rxvt -name rippa -pixmap ~/pics/ripparxvt1.xpm -e vim ~/download/.rippage ; ~/.LOCAL_APPS/stream2mp3.sh `cat ~/download/.rippage`

In the file .rippage I put 2 separate strings of text on one line, then the stream2mp3.sh uses them as $1 and $2 through using the output of cat on .rippage. those ` characters are great, and this method is a good hands off approach to modifying specific args in a script you often run from a fluxbox menu without needing to run it from the shell.

This works alright, and I have flexibility, like being able to use xedit, vim with a rxvt custom background (not gvim, b/c the next queued command runs while gvim runs) and perhaps other editors. Is there not a better way, though? Maybe an operation built into bash? I made this way up, AFAIK, but am I reinventing the wheel?

Thanks for the help, Community!













--Tangent:$


For those interested in a cool way to use your fluxbox menus with other computers on the network, this is one tweak of your menu file:

[submenu] (Goodies)
[exec] (Stream Rippa) {rxvt -name sshcmd -g 50x10 +sb -pixmap ~/pics/egorip.xpm -font -*-fixed-medium-r-*-*-30-*-*-*-*-*-iso8859-* -fg green -name "egorip" -e ssh lionheart@egomenace ~/scripts/rippa.sh}
[end]

The content of rippa.sh is in the first paragraph, but here is the content of stream2mp3.sh:

mplayer -dumpstream -dumpfile $2 -playlist $1
mplayer -ao pcm:file=$2.wav $2
lame -h -v -b 128 $2.wav $2.mp3

This is how I'm converting playlist type streams to mp3s. I paste the stream url first and type the mp3 name I chose second into vim. I don't automate the removal of the initial file and the wav file for my own reasons, but in the future I might, but I'll wrap it in 'find' to make sure it only deletes wavs from the last hour or so.

Why use ssh to rip these streams on a separate computer? I thought my computer was fast, but when I use mplayer to rip streams like how I demonstrate above, this computer becomes unstable. I can barely switch desktops, open apps, type, etc. I can do it on the headless machine without disrupting my work flow.

But, yes, fluxbox menus are great -- they can make life so much easier. Ever have a program you have to kill every now and then? For me, those programs are mplayer and firefox:

[submenu] (Slayer)
[nop] (Slay this sh*t, yo)
[exec] (Slay Mplayer) {killall mplayer && killall mplayer}
[exec] (Slay Firefox) {killall firefox && killall firefox-bin}
[end]

I kill mplayer twice, because firefox uses 2 mplayer processes.

Maybe next time I'll post snippets of my submenu/customenu that uses find to create playlists based on either video age, access time or file size, and uses mplayer to play them all in full screen. Of course, since it's a fluxbox menu, I created a thousand variations of ways to feed these playlists to mplayer (randomly, with different edl files for party-mode effects, no sound, different video drivers/audio drivers, edl recording mode to make new edls for a movie or party; animated gif mode, where playing the video uses a specific edl file and makes an animated gif). Some of these options use the rxvt window popup input for experimentation on bluray encodes, or whatever other lesser used arguments I have not yet made clickable.

It's all just bash, but within the reach of a mouse click.

Last edited by Anithen; 07-10-2008 at 11:22 PM. Reason: punctuation
 
Old 07-11-2008, 02:55 AM   #2
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
I don't know if this is what you want, but you can read user input in a GUI from shell script using xdialog:
http://xdialog.free.fr/
 
Old 07-11-2008, 03:16 AM   #3
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
or man zenity
 
Old 07-11-2008, 05:20 AM   #4
Anithen
Member
 
Registered: Aug 2003
Location: Florida
Distribution: Slackware 12, Slackware 12.1, Slackware 12.2
Posts: 105

Original Poster
Rep: Reputation: 15
H_TeXMeX_H: Thanks for letting me know about xdialog. It's exactly what I had in mind. I did not expect there to be so many options. I hate to admit this, but it seems confusing. It can be very handy, though -- especially being able to have the directory and file selection. Now I won't have to use Emelfm for all file operations.

Mr. C.: Thanks for your suggestion, too. It looks like zenity is gnome based, so I'm not going to be able to install that just yet, but thank you for your words. As with Texmex, your suggestion showed me that applications like this do, indeed, exist.
 
Old 07-11-2008, 06:02 AM   #5
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,012

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
zenity works fine with KDE

You might also look at kdialog There's some information here:
http://www.linuxtopia.org/online_boo...y.html#kdialog
Eg
Code:
tred@vaio:~$ kdialog --title 'Wireless Network Detected'  --yesno 'Do you want to connect to the Internet?'
tred@vaio:~$ echo $?
tred@vaio:~$ kdialog --help
 
Old 07-11-2008, 08:05 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Ditto: I use Zenity in KDE systems.

It's a common misconception that you can't mix KDE and GNOME apps. Note that Zenity is not "Gnome-based"--it is GTK-based. All you have to do is install the right libraries
 
Old 07-11-2008, 08:32 AM   #7
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
As you're a Slacker, check out how the netconfig utility works (it's the script that during install prompts for network parameters). It uses a command dialog (see man dialog for more info).

Not sure if it's the same as the earlier mentioned xdialog or something totally different.
 
Old 07-11-2008, 09:56 AM   #8
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
xdialog is the X11 version of the curses based dialog. If curses is fine for you, use dialog.
 
Old 07-12-2008, 03:53 PM   #9
Anithen
Member
 
Registered: Aug 2003
Location: Florida
Distribution: Slackware 12, Slackware 12.1, Slackware 12.2
Posts: 105

Original Poster
Rep: Reputation: 15
Hey, guys, Thanks for the clarification. The zenity website mentioned gnome, so I just back peddled away from it. Xdialog is installed now, and I'm reserching how to use it with my scripts.

And thanks for mentioning dialog, my friend from South Africa. I was looking into that after reading about xdialog. I think X based menus will be nicer for this instance. I'll probably experiment with both (like whether dialog allows for showing the pixmap background of rxvt).

Thanks, All. I knew there had to be a more official alternative to what I'm doing.

Last edited by Anithen; 07-12-2008 at 10:54 PM. Reason: spelling
 
Old 08-06-2008, 03:14 PM   #10
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 46
Don't forget getgui. Very easy to use, has no dependencies to worry about, lightweight (182kb tarball) and works!.
 
Old 08-24-2008, 01:51 PM   #11
Anithen
Member
 
Registered: Aug 2003
Location: Florida
Distribution: Slackware 12, Slackware 12.1, Slackware 12.2
Posts: 105

Original Poster
Rep: Reputation: 15
Wow, /bin/bash. getgui seems really nice. Grabbing it now.

Last edited by Anithen; 08-24-2008 at 01:51 PM. Reason: forgot to space
 
  


Reply

Tags
bash, fluxbox, menu


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 Help! When reading input from a user sfmadmax Linux - Newbie 3 12-12-2007 12:03 AM
Help Please - averging input in a shell script reddawn Linux - Newbie 2 07-16-2006 01:44 PM
how can I take input with a shell script? GUIPenguin Linux - General 4 04-11-2005 03:46 PM
Shell script user input tuckermaddox Linux - Newbie 5 08-12-2004 03:14 AM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 03:00 PM


All times are GMT -5. The time now is 07:23 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration