3

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?

2 Answers2

5

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.

0

For me according to http://ubuntuforums.org/archive/index.php/t-1680158.html this recepie works:

xdotool key --clearmodifiers XF86MonBrightnessDown

And from man xdtool it means a following:

CLEARMODIFIERS
   Any command taking the --clearmodifiers flag will attempt to clear any
   active input modifiers during the command and restore them afterwards.

   For example, if you were to run this command:
    xdotool key a

   The result would be 'a' or 'A' depending on whether or not you were
   holding the shift key on your keyboard. Often it is undesirable to have
   any modifiers active, so you can tell xdotool to clear any active
   modifiers.

   The order of operations if you hold shift while running 'xdotool key
   --clearmodifiers a' is this:

   1. Query for all active modifiers (finds shift, in this case)
   2. Try to clear shift by sending 'key up' for the shift key
   3. Runs normal 'xdotool key a'
   4. Restore shift key by sending 'key down' for shift

   The --clearmodifiers flag can currently clear of the following:

   ·   any key in your active keymap that has a modifier associated with
       it.  (See xmodmap(1)'s 'xmodmap -pm' output)

   ·   mouse buttons (1, 2, 3, 4, and 5)

   ·   caps lock