#!/bin/bash
#set -x

echo "Loaded Graphics Cards Kernel Drivers:"
nvidia_output=$(lspci -nnk | grep -A 3 -P '^(\d{4}:)?\d{2}:\d{2}\.\d\s+VGA compatible controller.*NVIDIA')

if [ ! -z "$nvidia_output" ]; then
	echo "-------------------------------------"
	echo "NVIDIA Graphics:"
	echo "$nvidia_output" | grep "Kernel driver in use"
	echo
fi

intel_output=$(lspci -nnk | grep -A 3 -P '^(\d{4}:)?\d{2}:\d{2}\.\d\s+VGA compatible controller.*Intel')
if [ ! -z "$intel_output"]; then
	echo "-------------------------------------"
	echo "Intel Graphics:"
	echo "$intel_output" | grep "Kernel driver in use"
	echo
fi

amd_output=$(lspci -nnk | grep -A 3 -P '^(\d{4}:)?\d{2}:\d{2}\.\d\s+VGA compatible controller.*AMD')
if [ ! -z "$amd_output"]; then
	echo "-------------------------------------"
	echo "AMD Graphics:"
	echo "$amd_output" | grep "Kernel driver in use"
	echo
fi
