Ubuntu – Changing media key defaults in Gnome

configurationgnomekeyboardscripts

Under XFCE, I had option to set my keyboard media keys to run particular programs or scripts. I understand the options to adjust the Keyboard Shortcuts under Gnome, but how do I change the default programs that the keys use.

For example, I have a script I use that manages my calculator (in this case, galculator). This script not only launches an instance of galculator but makes sure that another instance is not running. So unlike the default manner under Gnome, if one instance is already running, it just brings focus to it). I am not having 15 different calculators to close out in the end.

I have tried looking under gconf and keyboard shortcuts. Any other ideas?

Best Answer

  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.