16

On my computer I have two USB keyboards plugged in. Instead of having both just type the same key, is it possible for a second keyboard to be setup to run commands instead of typing letters? And If that's not possible, can it be setup to at least type in another language like Russian for example?

  • Do you want to bind specific commands to chosen keys of second keyboard to be able only run something and not type letters? – pbm Apr 4 '12 at 19:08
  • And next question: do you want to use shortcuts for running background applications (or application in X environment) or just type name of the command in active terminal using keyboard shortcut? – pbm Apr 4 '12 at 19:26
  • Alternative way to disable sending keys to applications. askubuntu.com/a/178741/554601 – Ariunbayar Jun 8 '16 at 7:57
15

This is my third answer when I can recommend actkbd... :)

So if you want to configure all keys of second keyboard to run commands not to type letters you can use actkbd... :)

After installing actkbd we need to find what device file is used to receive events from out keyboard:

pbm@tauri ~ $ cat /proc/bus/input/devices 
[cut]
I: Bus=0003 Vendor=046d Product=c31c Version=0110
N: Name="Logitech USB Keyboard"
P: Phys=usb-0000:00:1a.0-1.1/input0
S: Sysfs=/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/input/input7
U: Uniq=
H: Handlers=sysrq kbd event5 
B: PROP=0
B: EV=120013
B: KEY=1000000000007 ff9f207ac14057ff febeffdfffefffff fffffffffffffffe
B: MSC=10
B: LED=1f

I: Bus=0003 Vendor=046d Product=c31c Version=0110
N: Name="Logitech USB Keyboard"
P: Phys=usb-0000:00:1a.0-1.1/input1
S: Sysfs=/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.1/input/input8
U: Uniq=
H: Handlers=kbd event6 
B: PROP=0
B: EV=1b
B: KEY=2010000 397ad801d001 1e000000000000 0
B: ABS=100000000
B: MSC=10
[cut]

On this list you should find your keyboard, and check it handlers. Use sudo actkbd -s -d /dev/input/HANDLER_NAME to check if that handler send events. If you run this command and press key on keyboard (check for keys that you want to bind to commands) you should get something like that:

pbm@tauri ~ $ sudo actkbd -s -d /dev/input/event5 
Keys: 57
Keys: 35

If you have keycodes we could create actkbd config file:

pbm@tauri ~ $ sudo nano /etc/actkbd.conf 
30:::sudo -u pbm DISPLAY=:0 amarok
//30 is keycode for letter a

When you save that file we should test if configuration works:

pbm@tauri ~ $ sudo actkbd -d /dev/input/event5 -D

When you press key that you have in your config file command from last column of config file will be started.

I think that there is a way to disable sending keys to applications, but I was unable to find it - check out README file.

Instead of trying to disable it using actkbd you could turn off your keyboard in X.

pbm@tauri ~ $ xinput list
[cut]
    ↳ Logitech USB Keyboard                     id=12   [slave  keyboard (3)]
    ↳ Logitech USB Keyboard                     id=11   [slave  keyboard (3)]
pbm@tauri ~ $ xinput set-prop 11 "Device Enabled" 0
pbm@tauri ~ $ xinput set-prop 12 "Device Enabled" 0

It should do the work... :) For more information about actkbd check out this answer.

Using actkbd (and few scripts probably) you can also configure your keyboard to change modes from command mode to input mode with Russian letters. For this read Ulrich Schwarz's answer.

  • 1
    I have asked this question a million times on a billion forums and you're the only one that actually new this. Thanks a trillion. – captainandcoke Apr 24 '12 at 2:12
0

I have written a small program in C which can just do that. I have written it 'on the fly', so it isn't very good, but it works. You can get it here.

  • Hello and welcome to the Unix and Linux Stack Exchange site. Please review the Help Center and take the Tour to learn more about this site. While your link may provide a solution to the user's issue could you please add additional context to your post? Currently this is just an offer to download software from a third party site. You should include what this does, how to install and use it, and why it answers the question at hand. Thank you. – kemotep Dec 30 '19 at 20:47

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.