If you are working on an ACPI system you can customize the behaviour of your ACPI buttons. These are: The Power and Sleep buttons and the Lid open/close "buttons".
Search for the button event configuration variables in /etc/sysconfig/powersave/events (also see Events).
You may also be able to catch other (multimedia) buttons that are ACPI driven. However, this mainly depends on your system. If your system provides ACPI driven buttons you can use one of the provided scripts or implement your own ones (see Scripts).