How to disable the behaviour of the power button on Ubuntu 20LTS

I am not sure what is wrong with your files.

  1. The logind-way

    Did you try

    sudo systemctl restart systemd-logind
    

    or (better) rebooting?

  2. The acpid-way

    Besides, this a possible method to obtain the behaviour you are looking for. Create an ACPI handler with a file in /etc/acpi/events/

    sudo nano /etc/acpi/events/powerbtn-acpi-support
    

    (Note: as per official info, "Rules are defined by simple configuration files. acpid will look in a configuration directory (/etc/acpi/events by default), and parse all regular files that do not begin with a period ('.') or end with a tilde (~).")

    Make that file contain

    event=button[ /]power
    action=
    

    Then restart the acpi daemon with

    sudo service acpid restart
    

Notes:

  1. The cardboard-way is funny.

Sources:

https://superuser.com/questions/1523918/run-script-when-power-button-pressed

https://wiki.archlinux.org/index.php/acpid

How to prevent the Power button to shutdown directly the system?

https://superuser.com/questions/699905/change-behavior-of-linux-power-button/699925


Ubuntu 20.04 LTS has it in the GUI controls. There is an option to make the power button "Do nothing" in the Power Button Behavior dropdown menu.
*
enter image description here