A window manager can be configured to ask (like
gnome-power-manager), but the system itself does not ask (e.g.: via
shutdown). Most computers now have an electronic power switch that sends a signal to the computer. The computer receives the signal and does whatever it was configured to do with it.
You didn't say which version. I think... I am not entirely sure, but I think I remember this being slightly different on different versions...
So... what's doing it? Open a terminal...
Is the button kernel module loaded? (
lsmod | grep button)
Yes? The kernel is receiving the signal and passing it to another program.
Is acpid running? (
ps -A | grep acpi)
Yes? ACPI (Advanced Configuration and Power Interface) handles the signal.
So let's look in /etc/acpi/... You should have a "powerbtn.sh" file or something similar depending on your version of Ubuntu and/or ACPI. At the end of that script you see what happens:
/sbin/shutdown -h -P now "Power button pressed"
And if we do a
man shutdown from a terminal, we can see the meaning of switches...
- -h Halt or power off after shutdown.
- -P Halt action is to turn off the power.
If you want to configure the button... this seems to be a good post if you are using Gnome. I am fairly certain that this is a version-specific question, but these I hope are good clues.