#! /bin/bash
if [ -z "$1" ]; then
        echo "missing parameter..."
        echo ""
        echo "usage:"
        echo "$0 LayoutEditor"
        echo "$0 ImageSetViewer"
        echo ""
        echo "or one of the installed demo applications:"
        myDemos=`ls -1 /usr/bin/mygui-Demo_*`
        echo $myDemos | sed -e 's|/usr/bin/||g'
        exit 1
fi

# create local working directory
if [ ! -d $HOME/.mygui ]; then
        mkdir -p $HOME/.mygui/Shared/linux

        # link the resources to local dir
        ln -s /usr/share/mygui/Media $HOME/.mygui
        # config should be user writeable
        cp /usr/share/mygui/*.cfg $HOME/.mygui/Shared/linux
fi
# just in case some new files appear (update)
ln -sf /usr/share/mygui/Media $HOME/.mygui

# call binary from local working-directory
cd $HOME/.mygui/Shared/linux
/usr/bin/$1
