PDA

View Full Version : [xubuntu] Using "extra" keys on xfce with Logitech keyboard



pdwerryhouse
October 18th, 2011, 12:51 AM
Hi all,

After upgrading to Oneiric, I've just started using xfce, because I can't stand Unity or Gnome 3. I've got one small issue however.

My keyboard (a Logitech Internet Navigator Keyboard) has a few extra buttons, notably Stop, Play, Skip and Back buttons for controlling a media player. Under Gnome 2, these buttons would control Rhythmbox (whether it was in focus or not).

Now they don't work at all. I'm sure I could probably throw together a nasty hack involving xmodmap and some shell scripts, but I'm wondering if there is a "correct" way to do this in XFCE?

I've already set the keyboard to "Logitech Internet Navigator" in the Keyboard settings.

Toz
October 18th, 2011, 02:46 AM
The default music player in Xubuntu (oneric) is gmusicbrowser. It provides a FIFO mechanism so that commands can be sent to the music player (documented in 'man gmusicbrowser').

You could create a script like:

#!/bin/bash

case $1 in
1) echo Stop > ~/.config/gmusicbrowser/gmusicbrowser.fifo
;;
2) echo PlayPause > ~/.config/gmusicbrowser/gmusicbrowser.fifo
;;
3) echo NextSong > ~/.config/gmusicbrowser/gmusicbrowser.fifo
;;
4) echo PrevSong > ~/.config/gmusicbrowser/gmusicbrowser.fifo
;;
*)
;;
esac

...and then assign the keystrokes using SettingsManager->Keyboard->Application Shortcuts so that:

Stop = /home/gm 1
Play = /home/gm 2
Skip = /home/gm 3
Back = /home/gm 4

where gm is the name of the script.

EDIT: Another solution exists here: http://ubuntuforums.org/showpost.php?p=11325883&postcount=14, but it involves enabling gnome services.

iamnotthemessiah
October 18th, 2011, 10:37 AM
i would like to know how to do this in banshee cos i cant stand gmusicbrowser

Toz
October 18th, 2011, 11:47 AM
@iamnotthemessiah, I don't and never have used banshee, but the man page says its possible: http://manpages.ubuntu.com/manpages/oneiric/en/man1/banshee.1.html. So try this:

#!/bin/bash

case $1 in
1) banshee --stop
;;
2) banshee --play
;;
3) banshee --next
;;
4) banshee --previous
;;
*)
;;
esac

TREESofRIGHTEOUSNESS
October 18th, 2011, 01:26 PM
Isn't there an overall type of command for this?
that you can set to your XF86(whatever-key)?
I had to manually insert some stuff to make a custom Volume control key
(amixer -q sset Master 1+ && amixer -q sset PCM 1+) instead of something like RaiseVolume, or whatever.

Toz
October 18th, 2011, 01:47 PM
Have a look at: http://wiki.xfce.org/faq#keyboard - section "Is it possible to use Media keys in the Shortcut Editor?".

Basically, in a terminal window, type:

xev | grep keycode
...and an input window will open, but that's not important. Look at the terminal window and press one of your multimedia keys. If you get a response like:

state 0x10, keycode 71 (keysym 0xffc2, F5), same_screen YES,
...then the key is being recognized by the system. The important part is the part in red ("keycode xxx").

Edit and/or create a ~/.Xmodmap file in your home directory to look something like:


keycode 162 = XF86AudioPlay
keycode 164 = XF86AudioStop
keycode 160 = XF86AudioMute
keycode 144 = XF86AudioPrev
keycode 153 = XF86AudioNext
keycode 176 = XF86AudioRaiseVolume
keycode 174 = XF86AudioLowerVolume
keycode 237 = XF86AudioMedia
keycode 230 = XF86Favorites
keycode 236 = XF86Mail
keycode 178 = XF86WWW
...but substitute the keycode values for the ones generated by the previous (xev | grep keycode) exercise.

To enable this new keymapping, type:

xmodmap ~/.Xmodmap
...at the terminal window or to make it permanent add that command to ~/.xprofile (manke sure that you make ~/.xprofile executable)

In theory this is how it should work. Unfortunately, I don't have a multimedia keyboard to test it out.