Skip to content

Commit

Permalink
Update model fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevithakannan2 committed Oct 23, 2024
1 parent 42a5ac8 commit bfc31b6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions core/tabs/system-setup/arch/nvidia-drivers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@ installDeps() {
done
}

checkHardware() {
checkNvidiaHardware() {
# Refer https://nouveau.freedesktop.org/CodeNames.html for model code names
model=$(lspci -k | grep -A 2 -E "(VGA|3D)" | grep controller | cut -d ' ' -f 7 | cut -c 1-2 )
model=$(lspci -k | grep -A 2 -E "(VGA|3D)" | grep NVIDIA | sed 's/.*Corporation //;s/ .*//' | cut -c 1-2)
case "$model" in
GM|GP|GV) return 1 ;;
TU|GA|AD) return 0 ;;
*) printf "%b\n" "${RED}Unsupported hardware." && exit 1 ;;
esac
}

checkIntelHardware() {
model=$(grep "model name" /proc/cpuinfo | head -n 1 | cut -d ':' -f 2 | cut -c 2-3)
[ "$model" -ge 11 ]
}

promptUser() {
printf "%b" "Do you want to $1 ? [y/N]:"
read -r confirm
Expand Down Expand Up @@ -82,7 +87,7 @@ setupHardwareAcceleration() {

installDriver() {
# Refer https://wiki.archlinux.org/title/NVIDIA for open-dkms or dkms driver selection
if checkHardware && promptUser "install nvidia's open source drivers"; then
if checkNvidiaHardware && promptUser "install nvidia's open source drivers"; then
printf "%b\n" "${YELLOW}Installing nvidia open source driver...${RC}"
installDeps
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm nvidia-open-dkms
Expand All @@ -92,6 +97,10 @@ installDriver() {
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm nvidia-dkms
fi

if checkIntelHardware; then
setKernelParam "ibt=off"
fi

# Refer https://wiki.archlinux.org/title/NVIDIA/Tips_and_tricks#Preserve_video_memory_after_suspend
setKernelParam "nvidia.NVreg_PreserveVideoMemoryAllocations=1"
"$ESCALATION_TOOL" systemctl enable nvidia-suspend.service nvidia-hibernate.service nvidia-resume.service
Expand Down

0 comments on commit bfc31b6

Please sign in to comment.