nvidia – Writing a script to be called with keyboard press

I am using Ubuntu 20.04 on a Dell XPS 15 7590. As you may know, my model has the OLED screen. Screen brightness functionality does not work so when I am using the intel card, I have to enter this in the terminal:

xrandr --output eDP-1 --brightness 0.5

And when I am using my NVIDIA card, I have to enter this:

xrandr --output eDP-1-1 --brightness 0.5

Is there a way I can write a script that will be invoked whenever I press Fn + F10/F11 to control the brightness? Here is a pseudocode:

if card = intel:
   xrandr --output eDP-1 --brightness 0.5
else:
   xrandr --output eDP-1-1 --brightness 0.5

Fn + F10 is suppose to increase the brightness. Fn + F11 is suppose to decrease the brightness.