#!/bin/bash
# 09980-fbdev-fallback.sh
# framebuffer fallback, only if a Linux framebuffer is actually available

XORG_CONF="$1"

[ -n "$XORG_CONF" ] || exit 2
[ -f "$XORG_CONF" ] || exit 2

# Need a real framebuffer device
[ -c /dev/fb0 ] || exit 1
[ -r /proc/fb ] || exit 1
grep -q . /proc/fb || exit 1

logger -t retrodebian-xorg-autoconfig "Configuring fbdev fallback for $PCI_DEVICE_NAME [$PCI_DEVICE_ID]"

sed -i \
    -e 's|{DeviceDriver}|fbdev|g' \
    "$XORG_CONF" || exit 2

exit 0