Friday, August 15, 2014

Configure evrouter on ubuntu 14.04

1) Install evrouter

2) Add a rule to allow users to read /dev/input/event*
echo 'KERNEL=="event*", NAME="input/%k", GROUP="input"' | sudo tee /etc/udev/rules.d/80-evrouter.rules

Create the input group
sudo addgroup input

Add this group at the user
sudo usermod -aG input ${USER}

3) Reboot the system

4) Keys identification, choose the good input, e.g.:
evtest
Available devices:
/dev/input/event0: Lid Switch
/dev/input/event1: Sleep Button
/dev/input/event2: Power Button
/dev/input/event3: AT Translated Set 2 keyboard
/dev/input/event4: SynPS/2 Synaptics TouchPad
/dev/input/event5: Logitech Unifying Device. Wireless PID:101d
/dev/input/event6: Chicony Multimedia Keyboard
/dev/input/event7: Chicony Multimedia Keyboard
/dev/input/event8: Video Bus
/dev/input/event9: HDA Intel Headphone
/dev/input/event10: HDA Intel Mic
Select the device event number [0-11]: 7

5) Create the config file
Create evrouter config file (${HOME}/.evrouterrc):
Run evrouter with -d option, press a key and copy the appearing line:

"Chicony Multimedia Keyboard" "/dev/input/event7" none key/423 "fill this in!"

My config file:
#Vol-
"Chicony Multimedia Keyboard" "/dev/input/event7" none key/421 "XKey/XF86AudioLowerVolume"

#Vol+
"Chicony Multimedia Keyboard" "/dev/input/event7" none key/423 "XKey/XF86AudioRaiseVolume"

#activate chromium
"Chicony Multimedia Keyboard" "/dev/input/event7" none key/150 "Shell/wmctrl -a Chromium > /dev/null 2>&1 &"

#activate krusader
"Chicony Multimedia Keyboard" "/dev/input/event7" none key/155 "Shell/wmctrl -a Krusader > /dev/null 2>&1 &"

#sysmon
"Chicony Multimedia Keyboard" "/dev/input/event7" none key/120 "Shell/gnome-system-monitor > /dev/null 2>&1 &"

If you want to run a program (for e.g. sysmon), you have to run it in background, otherwise you won't be able to run other commands, until system monitor is opened.

6.) Execute evrouter
evrouter /dev/input/event7

7.) Make autostart script
After a few restart I realized, that my keyboard got another event id and I had to modify the config file every time. To avoid that, I made a short script, that you can modify and add to autostart:

#!/bin/bash

event_oldid=`cat .evrouterrc | grep "Chicony Multimedia Keyboard" | grep -o "event[0-9]\|event[0-9][0-9]" | head -1`

event_id=`ls -l /dev/input/by-id | grep "usb-Chicony_Multimedia_Keyboard-event-if01" | grep -o "event[0-9]\|event[0-9][0-9]"`

sed -i "s/$event_oldid/$event_id/g" .evrouterrc

evrouter /dev/input/$event_id

2 comments:

  1. Be careful! I had issues upgrading to 15.04 because it tries to create an "input" group, and I had already created an input group, as per these instructions.

    I suggest using another name to avoid issues!

    Bug report: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1455956

    Fix was manually removing the input group, and then running dpkg --reconfigure -a to let udev configure itself.

    ReplyDelete
  2. Oh, didn't know about that, I'm still on 14.04. Thanks for feedback, I'll be careful at next upgrade.

    ReplyDelete