#!/usr/bin/env bash
#
# This will build a wmconfig compatible file from a directory hierarchy
# of menus (usually used by AfterStep and such)
#
#	$Id: from-files.sh,v 1.3 2004/09/24 15:28:01 cvs Exp $
#	$Log: from-files.sh,v $
#	Revision 1.3  2004/09/24 15:28:01  cvs
#	
#	
#	Updates for Version 1.2.1
#	
#	Revision 1.2  2004/05/29 21:28:27  cvs
#	
#	
#	Version 1.1.7
#	
#	Revision 1.1  1998/04/22 14:12:12  gafton
#	New file
#	
#	Revision 1.1  1998/04/22 07:46:55  gafton
#	Enhanced afterstep sypport; read extra files from command line
#
#

if [ -z "$1" ] ; then
    echo "Usage: $0 <directory>"
    exit
fi

if [ ! -d $q ] ; then
    echo "$1 is not a directory"
    exit
fi

find $1 -type f \
    -printf "echo -e \"auto%i name \\\"%f\\\"\\\nauto%i group \\\"%h\\\"\\\nauto%i exec \`cat '%p'\`\"\n" \
    2>/dev/null | \
    sed -e "s|\"$1/|\"|g" -e "s|\"$1|\"|g" | \
    sh -
