2

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?

3

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.

6
  • Thanks, it would help if I could find the keyboard shortcuts application. I'm on the preferences tab but nothing says "keyboard shortcuts" so I'm at a loss here. Does it have a code to launch from terminal? Maybe it isn't installed on my computer at all? I have Lubuntu – Richárd Fejes Aug 7 '13 at 15:24
  • Hit Dash (Top Left) => Search for Keyboard. When it opens, click the next tab (Shortcuts), then hit the + Sign at the bottom of the Keyboard application. Type in a name and your command. – sameetandpotatoes Aug 7 '13 at 15:28
  • That's gonna sound dumb, but all i see is my desktop. There is this bar which resembles to the windows start menu with a start button. I have hungarian keyboard, but there is a dash on it. It makes this character: "-" When i'm pushing this on the desktop nothing is happening. I also tried with "Run" but it doesn't working. Where can I search for keyboard? – Richárd Fejes Aug 7 '13 at 15:42
  • I'm sorry for not being clear. The Start button is called Dash. I'm not referring to the dash on a keyboard. Click the Start Button. I'm talking about this button in the top left that's highlighted in that picture where you can search for Applications. – sameetandpotatoes Aug 7 '13 at 15:53
  • I'm so grateful that you are this patient with me but still I have to remind you, i have Lubuntu, which only has the dash and a desktop. I kinda feel myself right now like a grandma :D – Richárd Fejes Aug 7 '13 at 16:03
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.