How can a script ask for user input under X?
January 23, 2009 2:18 AM   Subscribe

What's a good way to make a script pop up an input box under X? Bonus points for blind password entry support and visual integration with XFCE.

I want to make a shell script that requires a small amount of user input --- a username/password pair for an openvpn connection --- that will be launched from a pannel button in XFCE.

I'm looking for a way to pop up an input box, collect the input and return it to my script without going to the trouble of writing a full-blown X application.

I know there are graphical openvpn front-ends out there, as well as ways to store the login credentials, but I keep coming accross this question from time to time and would like to find an reusable solution.
posted by ghost of a past number to Computers & Internet (3 answers total) 1 user marked this as a favorite
 
There's a utility called zenity(1) that is installed by default on Ubuntu and is probably available on other distros as well that allows you to use all the basic GTK+ dialogs in shell scripts. Basic usage is something like this:

#!/bin/bash
TEXT_ENTRY=`zenity --entry`
echo "You entered $TEXT_ENTRY"

This should be what you need.
posted by DecemberBoy at 2:29 AM on January 23, 2009


Oh, and for password entry you would need to use "zenity --entry --hide-text".
posted by DecemberBoy at 2:39 AM on January 23, 2009


Zenity won't do it for me, as it's a Gnome app --- compiling all the gnome dependencies would be almost as much work as rewritting the thing from scratch, not to mention the bloat.

It has however led me to Xdialog, which looks like it will do the trick.
posted by ghost of a past number at 2:43 AM on January 23, 2009


« Older Power for my PC   |   Is it possible to beatmix with only one ear? Newer »
This thread is closed to new comments.