[dwm] xpw: x piped widgets

From: pancake <pancake_AT_youterm.com>
Date: Sun, 8 Jul 2007 12:25:35 +0200

Yesterday I started to write a new application for X that accepts commands from
stdin and prints the result to stdout. It aims to easily create minimalistic GUIs.

Widgets are disposed using a restack() function that tries to move all the widgets
to properly fit on screen. My idea is to create a tiling widget program to create
simple interfaces that get rid on the tiling window managers ideas.

Here's a sample application written in C (demo_widgets()@main.c). You should
uncomment the call from main():


void demo_widgets()
        widget_add( xpw_label("msg", "Username") );
        widget_add( xpw_entry("user", "anonymous") );
        widget_add( xpw_newline("nl", ""));
        widget_add( xpw_label("msg", "Password") );
        widget_add( xpw_entry(".pass", "****") );
        widget_add( xpw_newline("nl", ""));
        widget_add( xpw_toggle("ssl", "Use SSL") );
        widget_add( xpw_button("options", "Options") );
        widget_add( xpw_newline("nl", "30"));
        widget_add( xpw_align("rule", "right"));
        widget_add( xpw_button("ok", "Ok") );
        widget_add( xpw_button("cancel", "Cancel") );
        widget_add( xpw_align("rule", "bottom"));
        widget_add( xpw_progress(".pb", "20") );

The current version have some problems when reading from stdin, looks like
`cat file | xpw` doesn't works but if you paste the lines using X or type
them manually it works :/ Can anybody light me about this bug?

This is another one-night-hack(R), so code is not as clean as I wish, but I'll
clean this progressively. Layout is actually a simple flow-layout, but in the
future i plan to design some tiling layouts.

Commands are entered from stdin and the result will be shown to stdout.

To add new widgets type:

 +label msg HelloWorld
 +entry name Your name
 +button ok Accept

Now you can get the value of the 'name' entry widget by typing:

 get name

I have written a simple script that needs some fixups to work, but the skel is:

rm -f .fifo
mkfifo .fifo

ciaociao() {
        echo exit > .fifo
        rm -f .fifo
        kill $$

while [ -e .fifo ] ; do cat .fifo ; done | ./xpw | while : ; do
        read A
        [ -z "$A" ] && echo byebye && echo exit > .fifo && exit
        echo "==> $A"
        [ "$A" = "button cancel" ] && ciaociao
        if [ "$A" = "button ok" ] ; then
                echo get user > .fifo && read USER
                echo get pass > .fifo && read PASS
                echo get ssl > .fifo && read SSL
                echo "USERNAME IS $USER"
                echo "PASSWORD IS $PASS"
                echo "USE SSL IS $SSL"
                xterm -bg black -fg gray -e ssh $USER@$HOST &

As you see this script needs the demo_widgets() function to be uncommented
to work. But here's the idea.

The configuration is done via config.h:

#define FONT "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*"
#define FGCOLOR "#707070"
#define BGCOLOR "#101010"
#define HGCOLOR "red"

Feel free to send me patches, ideas, tips, etc.. My original idea was to
use this program on embedded devices to create simple and lightweight
scriptable GUIs that allowed me to design them on a desktop and make it
run on 240x320 without gui redesign.

JOKING: maybe in the future we will have tiling applications running on
a tiled window manager and both will be able to "talk" to automatically
get a better layout.

Have fun!!

Received on Sun Jul 08 2007 - 12:26:43 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 14:45:49 UTC