Saturday, August 16, 2014

Audacious workaround: "Jump to track" is not active window when summoned with global hotkey

Here is the bug report. We could easily solve the issue with custom keyboard shortcut, but it doesn't work in ubuntu 14.04.
We can use evrouter for this purpose. You just have to add the following lines to config file ($HOME/.evrouterrc) and modify the key value, the name of your keyboard and event id.
If you don't know how to do it, see my previous post about configuring evrouter.

#audacious jump to song
"Chicony Multimedia Keyboard" "/dev/input/event7" none key/425 "Shell/(audacious -j; sleep 0.2; wmctrl -Fa 'Jump to Song') > /dev/null 2>&1 &"

Note:
audacious -j is for displaying jump to file dialog. After that we need use sleep for a moment, while window manager gets the details of the new window. Now we can activate it with wmctrl command.
(When audacious is closed, the command just opens the program).
Maybe you have to increase sleep value on a slower/busy computer. I tested it with 0.2 second and it worked always.

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