Changing media key defaults in Gnome

Solution 1:

  1. Open Keyboard Shortcuts (System -> Preferences -> Keyboard Shortcuts). By default you would see "Launch Calculator" action mapped to XF86Calculator, click on it and press Backspace to leave it disabled.

  2. Click on Add button to get "Custom Shortcut" dialog. Enter name as "My Calculator Script" and command as the full path to your script. Click OK.

  3. You will find this new shortcut at the end of the list. Click on it (you will see shortcut entry against it will change from Disabled to New Shortcut...).

  4. Press the XF86Calculator key (the special calculator key on your keyboard)

  5. Press Close to close this dialog. This should now run your script when you press the calculator key.