suspend – Different behaviour when closing laptop lid depending on power source – Ubuntu 20.04

I am new to using Ubuntu and I wanted to replicate my laptop’s behaviour from when I was running Windows. I would like to make it so that closing the lid triggers a different action depending on the current power supply:

  • when on battery – hibernate
  • when plugged in – suspend

I found multiple solutions that alter the /etc/systemd/logind.conf file, but changing the configuration there applies the action regardless of the power supply.

I also found answers that use dconf Editor, but that doesn’t seem to work for me.
I have the following settings, but the laptop always suspends when I close the lid.

enter image description here

Is there any other way of accomplishing said behaviour? Or does anyone have an idea why is the dconf Editor setting not working for me?