#!/bin/sh
X_CONF=xorg.conf
rm -f /etc/X11/$X_CONF.pure /etc/X11/$X_CONF.rej
cp /etc/X11/$X_CONF /etc/X11/$X_CONF.pure
if ! grep -q "Device.*Configured Video Device" /etc/X11/$X_CONF; then
 echo 'Warning: Adding "Configured Video Device" to "Screen" Section.' >&2
 perl -pi -e 's/(^\tMonitor\t\t"Configured Monitor"\n)/\1\tDevice\t\t"Configured Video Device"\n/' /etc/X11/$X_CONF
fi
patch --no-backup-if-mismatch /etc/X11/$X_CONF <<'EOT'
Index: xorg.conf
@@ -31,6 +31,7 @@
 
 Section "Device"
 	Identifier	"Configured Video Device"
+	Driver		"vesa"
 EndSection
 
 Section "Monitor"
@@ -41,6 +42,11 @@
 	Identifier	"Default Screen"
 	Monitor		"Configured Monitor"
 	Device		"Configured Video Device"
+	DefaultDepth	24
+	SubSection	"Display"
+		Depth	24
+		Modes
+	EndSubSection
 EndSection
 
 Section "ServerLayout"
EOT
if [ $? -ne 0 ]; then
 echo Error: Unable to patch. Please manually fix file! >&2
 rm -f /etc/X11/$X_CONF
 mv /etc/X11/$X_CONF.pure /etc/X11/$X_CONF
 exit 1
else
 echo Warning: Patch applied successfully. >&2
fi
