assigning a rotation script to a hardware button

Solution 1:

This is usually done via ACPI calls. First of all make sure that acpid daemon is installed and running. Then you will need to create rule for it to start your script when button is pressed. The tricky part here is to identify the button name. You can do it by running acpid daemon in foreground with debugging enabled and then press the button. If you see some messages then write down the button name and use it to write a rule that calls your custom script. Read man acpid for details.