Screen brightness is flickering up and down randomly on Ubuntu 20.04 [duplicate]

First get the source and build deps: (In "Software & Updates" make sure you have "Source Code" checked off.)

apt source gnome-settings-daemon
sudo apt build-dep gnome-settings-daemon

Then in plugins/power/gsd-power-manager.c, change the value of GSD_AMBIENT_SMOOTH to a lower value. I'm using 0.05f and it might be a bit too low.

Save changes:

cd gnome-settings-daemon-*
dpkg-source --commit

You will be asked to name the patch and write a summary file.

Then rebuild:

debuild

The "debuild" command may need to be installed via sudo apt install devscripts.

Then install:

sudo dpkg -i ../gnome-settings-daemon_*.deb

To add to the previous answer https://askubuntu.com/a/1139372/1083623 and answer the question by Verax in it's comments:

Install umockdev and it's GObject Introspection package

sudo apt install gir1.2-umockdev-1.0

I also had to use flags to disable digital signing during build:

sudo debuild -uc -us