diff --git a/zprofile b/zprofile index e01fdf6..40820bb 100644 --- a/zprofile +++ b/zprofile @@ -15,3 +15,21 @@ fi export PKGEXT=".pkg.tar" export TENDS_TO=42 + +DISTRO=$(cat /etc/os-release | grep '^ID=' | awk -F'=' '{print $2}') + +if [ $DISTRO = 'arch' ]; then + # configure VA-API for hardware video acceleration + VIDEO_DRIVERS=($(ls /usr/lib/dri | grep drv_video | awk -F_ '{print $1}')) + VIDEO_DRIVERS_LEN=${#VIDEO_DRIVERS[@]} + + if [ $VIDEO_DRIVERS_LEN -eq 1 ]; then + export LIBVA_DRIVER_NAME=$VIDEO_DRIVERS + elif [ $VIDEO_DRIVERS_LEN -gt 1 ]; then + if [ ! -v $LIBVA_DRIVER_NAME]; then + echo "Warning: more than one VA-API driver detected! Found: ${VIDEO_DRIVERS}." >&2 + echo "Either delete the wrong driver or choose one manually by setting LIBVA_DRIVER_NAME." >&2 + fi + fi + export LC_ALL=C +fi