#!/bin/bash

editlines() {
    IFS=" "
    read XPM
    while [ ! -z "$XPM" ]; do
        # echo "XPM='$XPM'"
        pixmap -f $XPM -geometry 1000x800-0-0 &
        read XPM
    done
}

expandxpm() {
    local XNAME=${1%.xpm}.xpm
    find $ARBHOME/lib/pixmaps -name "$XNAME"
}

expandxpms() {
    expandxpm $1
    shift
    if [ ! -z "$1" ]; then
        expandxpms $*
    fi
}


if [ -z "$ARBHOME" ]; then
    echo '$ARBHOME not set'
else
    if [ -z "$1" ]; then
        echo "Usage: arb_xpm [xxx[.xpm]]+"
        echo "Edit all given xpms using pixmap"
        echo "If a xpm occurs multiple times, all get edited"
    else
        expandxpms $* | editlines
        XPM=`find $ARBHOME/lib/pixmaps -name "$XNAME"`
    fi
fi
