Improve the grub manipulation script

This commit is contained in:
Manuel Thalmann 2024-06-19 14:09:48 +02:00
parent f2414083d6
commit b12a7dcf0e

View file

@ -1,4 +1,9 @@
#!/bin/bash
function install() {
local cmdindicator="GRUB_CMDLINE_LINUX_DEFAULT=\"";
local config="nvidia_drm.fbdev=1";
# According to: https://wiki.archlinux.org/title/NVIDIA/Tips_and_tricks
{
echo "options nvidia NVreg_PreserveVideoMemoryAllocations=1";
@ -9,3 +14,16 @@ sudo systemctl enable \
nvidia-suspend.service \
nvidia-hibernate.service \
nvidia-resume.service;
if ! cat /etc/default/grub | grep "$cmdindicator.*$config" > /dev/null;
then
sudo sed -i /etc/default/grub \
-e "/$cmdindicator/{" \
-e "s/\($cmdindicator.*[^ ]\)\(\"\)/\1 \2/" \
-e "s/\($cmdindicator.*\)\(\"\)/\1$config\2/" \
-e "}" \
;
fi;
}
install;