# Created by Tobias Powalowski <tpowa@archlinux.org>

run_hook ()
{
  # check for kms
  if [ "$intel_kms" = "y" ]; then
    msg ":: Switching to intel kms mode..."
    # writing module options
    echo "options i915 modeset=1" >> /etc/modprobe.d/modprobe.conf
    fbmodule="i915"
  else
    echo "blacklist i915" >> /etc/modprobe.d/framebuffer_blacklist.conf
  fi
  if [ "$nvidia_kms" = "y" ]; then
    msg ":: Switching to nvidia kms mode..."
    # writing module options
    echo "options nouveau modeset=1" >> /etc/modprobe.d/modprobe.conf
    fbmodule="nouveau"
  else
    echo "blacklist nouveau" >> /etc/modprobe.d/framebuffer_blacklist.conf
  fi
  if [ "$ati_kms" = "y" ]; then
    msg ":: Switching to ati kms mode..."
    # writing module options
    echo "options radeon modeset=1" >> /etc/modprobe.d/modprobe.conf
    fbmodule="radeon"
  else
    echo "blacklist radeon" >> /etc/modprobe.d/framebuffer_blacklist.conf
  fi
  # check for uvesafb
  if [ "$(echo $uvesafb | grep "[0-9]*x[0-9]*-[0-9]*")" ]; then
    msg ":: Switching to uvesafb mode..."
    sed -i -e "s#options.*#options uvesafb mode_option=$uvesafb scroll=ywrap#g" /etc/modprobe.d/uvesafb.conf
    fbmodule="uvesafb"
  fi
  # load correct module
  if ! [ "$fbmodule" = "" -a "$fbmodule" = "y" ]; then
    depmod -a
    msg ":: Loading ${fbmodule}..."
    modprobe -aq $fbmodule >/dev/null 2>&1
  fi
}
