#!/bin/sh
# if /etc/X11/xorg.conf.d/20-armsoc.conf is still there, every full filled windows move will be slow as with 3d acceleration

able=$1
packages="veyron-libgl xf86-video-armsoc-rockchip"

if [ "$able" == "" -o \( "$able" != "enable" -a "$able" != "disable" \) ]
then
 echo "syntax: $0 [enable|disable]"
 exit 0
fi

if [ "$able" == "enable" ]
then
  args=-S
  for package in $packages
  do
    pacman -Q $package 2>&1 >/dev/null; ret=$?
    if [ $ret -eq 1 ]
    then
      args="$args $package"
    fi
  done
  echo "pacman $args"
  pacman $arcs
  cd /usr/lib
  rm libEGL* libGLESv1_CM* libGLESv2*
  ln -s mali-egl/* .
elif [ "$able" == "disable" ]
then
  args=-R
  for package in $packages
  do
    pacman -Q $package 2>&1 >/dev/null; ret=$?
    if [ $ret -eq 0 ]
    then
      args="$args $package"
    fi
  done
  echo "pacman $args"
  pacman $args
  cd /usr/lib
  rm libEGL* libGLESv1_CM* libGLESv2*
  ln -s mesa/libEGL* mesa/libGLESv1_CM* mesa/libGLESv2* .
fi
ldconfig
