Lost macbook pro LCD backlight brightness controls after installing nvidia driver

I installed Ubuntu 20.04 LTS with the 5.11.0-34-generic kernel on my mid-2009 macbook pro which has nvidia geforce 9400M graphics hardware. Suspend and wake from suspend does not work with the nouveau open source graphics driver, so I wanted to install the nvidia proprietary graphics driver. The nvidia driver available within 'Additional Software' is the correct version for my machine, but it doesn't support the 5.11 kernel, so I installed the patched nvidia driver for my machine using the following from https://launchpad.net/~kelebek333/+archive/ubuntu/nvidia-legacy:

sudo add-apt-repository ppa:kelebek333/nvidia-legacy
sudo apt update
sudo apt install nvidia-340
sudo reboot

This enabled suspend and wake from suspend perfectly, but had the undesirable side effect of disabling the LCD brightness controls from both the macbook pro keyboard shortcut keys (F1 and F2), from the desktop GUI controls, and from settings. The keyboard backlight controls and volume controls all still work. LCD brightness controls had previously worked 'out of the box' with the nouveau graphics driver.

Would appreciate advice on how to get LCD backlight control functionality back after installing the nvidia driver.


After posting my question I found this answer from AskUbuntu's suggested answers. This worked and restored both keyboard and GUI LCD backlight brightness control functionality.

This is the link to the answer: https://askubuntu.com/a/199652/1128472.

These are the steps I followed from the answer:

# first I created the following file using this script. A blank text editor window opened.
sudo gedit /usr/share/X11/xorg.conf.d/10-nvidia-brightness.conf

# Next I pasted the following into the file and then saved and quit the text editor.
Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Quadro K1000M" # I changed this to "GEFORCE 9400M"
    Option         "RegistryDwords" "EnableBrightnessControl=1"
EndSection

# Lastly, I rebooted
sudo reboot