AAF: AAOBloggers


An easy and rapid GUI design with xmessage RETRO-STYLE (On Linux, BSD, and anything else running X)

leave a comment »

Probably at one point in your life, you will wake up wanting to create a GUI fast! whether it’s a front-end for some software you are writing, or just for the heck of it (i said probably). this simple how-to will teach you how to do just that.

The objective of this article is to design a GUI as fast and as effortlessly as possible. if you want more flashy GUI similar to what you usually get when you start a program, I’d recommend glade.

because we want the least effort we will be using bash (yes a terminal) to deploy and manage our GUI. The key player is xmessage (see “man 1 xmessage” for more detail). this is a simple yet incredibly useful program that displays a simple GUI dialog on the screen. its simplest form is:

xmessage "SIG is cool"

try that in your terminal and hit enter. if you did, you will see the following window:

see, even X thinks i’m cool :p

there are other futures that make xmessage more user friendly, and more usable. for instance, add the -default okay switch to activate the okay button when you hit enter. also, you can load an entire text file in the text area by using -file.

now, how about adding a few extra buttons? you can add more buttons by using the -buttons switch. two buttons are added: “yes”, and “no”. “yes” is the default. the command:

xmessage "SIG is cool" -buttons "yes:10, no:11" -default yes


run it.

at this point you might be wondering how this can help make a robust GUI for your application. this is where bash really comes in. open a text editor and write the following:

#! /bin/bash
xmessage -center "SIG is cool" -buttons "yes:10, no:11" -default yes
if [ $answer -eq 10 ]; then
        xmessage -center "You rock man" -default okay
        xmessage -center ";_; ... i'm not crying ..." -default okay

this is a simple bash script that behaves in the following manner:

"SIG is cool"
  +-> yes: "You rock man"
  +-> no: ";_; ... i'm not crying ..."

first save your script as “sig.sh”. then add excution permissions:

cd /your/scripts/directory
chmod +x sig.sh

once this has been done, simple start the script by issuing: (while still in the same directory)


or you can double click, and choose run. any way you do it you should get the following:

if you choose yes, and

if you choose no…



Written by seininn

March 4, 2009 at 10:15 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: