Ubuntu – Bind command lines to keys

key-bindingkeycodes

Is there a way to make this command line to activate every time i press a certain button?

xdotool key XF86MonBrightnessDown

I mean how can I bind it to a key? Also, which one of the keycodes are important and need to be used when binding? Scancode keycode or key number?

Best Answer

If you go to System ▸ Preferences ▸ Keyboard Shortcuts, you should be able to add your command and set the keybinding.

Alternate Way - make it into a script

First, open up a Terminal (Ctrl + Alt + T)

sudo touch /bin/anyName
sudo chmod +x /bin/anyName
sudo gedit /bin/anyName

Place this in the anyName file:

#!/bin/bash

xdotool key XF86MonBrightnessDown

Open your Keyboard Shortcuts application.
Create a new custom shortcut.

Set the command to "anyName", and pick the key combo (This can be done by pressing the key and Ubuntu will recognize which key you pressed. You don't have to worry about the scancode or keycode; just type what key combination you want to activate the command).

Hope this helps.

A related question on AskUbuntu.

A question on UbuntuForums.

Related Question