I have an HTPC and it needs to be suspended with the convenience of using the physical power button on the casing, Even when the screen lock appears on the display! After leaving the Ubuntu 18.04 system idle for a while,as per the configured settings, it activates the screen lock. After doing so, the single press of the physical power button on the computer does not suspend it anymore. I would have really wanted to work. If i unlock the screen, and subsequently press the power button, the suspend works. Can anyone help to overcome the behavior where the power button does not work when the lock is active?
I found a superuser answer that applies to your situation:
Someone pointed me to the file
/etc/systemd/logind.conf. I was able to set parms that allowed the suspend key to work in any situation regardless what the system requests. Here is an example of my settings.
For some reason a restart was not applying the changes, so I had to run the following command:
sudo systemctl restart systemd-logind