#!/bin/sh
#	cat /etc/haps/config/*.XF86Config 2>/dev/null >> /etc/haps/XF86Config.haps

#	cat /etc/sysconfig/mouse | /etc/haps/cut_haps > /etc/haps/mouse
#	echo "# HAPS_BEGIN" >> /etc/haps/mouse
#	cat /etc/haps/config/*.mouse 2>/dev/null >> /etc/haps/mouse
#	echo "# HAPS_END" >> /etc/haps/mouse

#	mv /etc/haps/XF86Config.haps /etc/X11/XF86Config.haps
#	mv /etc/haps/fstab /etc/fstab
#	mv /etc/haps/modules /etc/modules
#	mv /etc/haps/modules.conf /etc/modules.conf
#	mv /etc/haps/mouse /etc/sysconfig/mouse

	echo 'Section "Module"' >> /etc/haps/XF86Config.haps
	echo '    Load        "dbe"' >> /etc/haps/XF86Config.haps
	echo '    Load        "extmod"' >> /etc/haps/XF86Config.haps
	echo '    Load        "xtt"' >> /etc/haps/XF86Config.haps
	echo '    Load        "type1"' >> /etc/haps/XF86Config.haps
	echo '    Load        "speedo"' >> /etc/haps/XF86Config.haps
	echo 'EndSection' >> /etc/haps/XF86Config.haps
	echo 'Section "Files"' >> /etc/haps/XF86Config.haps
	echo '    RgbPath	"/usr/X11R6/lib/X11/rgb"' >> /etc/haps/XF86Config.haps
	echo '    FontPath   "/usr/share/fonts/local/"' >> /etc/haps/XF86Config.haps
	echo '    FontPath   "/usr/share/fonts/misc/"' >> /etc/haps/XF86Config.haps
	echo '    FontPath   "/usr/share/fonts/75dpi/:unscaled"' >> /etc/haps/XF86Config.haps
	echo '    FontPath   "/usr/share/fonts/100dpi/:unscaled"' >> /etc/haps/XF86Config.haps
	echo '    FontPath   "/usr/share/fonts/Type1/"' >> /etc/haps/XF86Config.haps
	echo '    FontPath   "/usr/share/fonts/Speedo/"' >> /etc/haps/XF86Config.haps
	echo '    FontPath   "/usr/share/fonts/75dpi/"' >> /etc/haps/XF86Config.haps
	echo '    FontPath   "/usr/share/fonts/100dpi/"' >> /etc/haps/XF86Config.haps
	echo 'EndSection' >> /etc/haps/XF86Config.haps
	echo 'Section "ServerFlags"' >> /etc/haps/XF86Config.haps
	echo 'EndSection' >> /etc/haps/XF86Config.haps
	echo 'Section "ServerLayout"' >> /etc/haps/XF86Config.haps
	echo '    Identifier  "HAPS Layout"' >> /etc/haps/XF86Config.haps
	echo '    Screen "Screen 1"' >> /etc/haps/XF86Config.haps
	for file in /etc/haps/config/*.XF86Config
	do
	    if grep -i 'driver.*keyboard' $file > /dev/null
	    then
		ID=`grep -i identifier $file | sed 's/identifier//i' | sed 's/[\"	 ]//ig'`
		echo '    InputDevice "'$ID'" "CoreKeyboard"' >> /etc/haps/XF86Config.haps
	    fi 
	    if grep -i 'driver.*mouse' $file > /dev/null
	    then
		ID=`grep -i identifier $file | sed 's/identifier//i' | sed 's/[\"	 ]//ig'`
		echo '    InputDevice "'$ID'" "CorePointer"' >> /etc/haps/XF86Config.haps
	    fi 
	    if grep -i 'section.*screen' $file > /dev/null
	    then
		ID=`grep -i "identifier.*screen" $file | sed 's/identifier//i' | sed 's/[\"	 ]//ig'`
		echo '    Screen "'$ID'"' >> /etc/haps/XF86Config.haps
	    fi 
	done
	echo 'EndSection' >> /etc/haps/XF86Config.haps
