Saturday, July 07, 2007

getting Griffin PowerMate Knob to work in linux

So my friend gave me this neat little USB knob called a Griffin PowerMate that can be used to control volume on your desktop, among other things:

These devices have been around for years and always wanted one. I tried hooking it up to my MacBook Pro first, but couldn't get it to work. So I thought I give it a shot in Linux. I checked out some relevant links on Google, but a number of them were only the driver files or APIs for accessing the device. I wanted a program that I could execute to have the PowerMate come alive in XMMS or the generic volume control in Gnome.

I found this site, and it provided a number of Ruby programs to get the device recognized in XMMS. But first I needed to install Ruby, as it was not on my system. This was a quick, 1.9MB install of Ruby and Ruby-libs:
[root@computer Desktop]# yum install ruby
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories ...
Parsing package install arguments
Resolving Dependencies ...
Dependencies Resolved =============================================================================
Package Arch Version Repository Size
============================================================================= Installing: ruby i386 updates 282 k
Installing for dependencies:
ruby-libs i386 updates 1.6 M
Transaction Summary
Install 2 Package(s)

Update 0 Package(s)

Remove 0 Package(s)
Total download size: 1.9 M
Is this ok [y/N]: y

Downloading Packages:

(1/2): ruby- 100% |=========================| 282 kB 00:00
(2/2): ruby-libs- 100% |=========================| 1.6 MB 00:02

Installed: ruby.i386 0:

Dependency Installed: ruby-libs.i386 0:

OK. Now to download the three programs responsible for controlling Ruby:

Plugging the device in to my Dell monitors' USB port, I saw that my Fedora Core 6 system recognized it:
usb 5-1.4: new low speed USB device using ehci_hcd and address 6
usb 5-1.4: configuration #1 chosen from 1 choice
input: Griffin PowerMate as /class/input/input4
usbcore: registered new interface driver powermate

I downloaded the programs to my $HOME directory and tested the driver program, xmmsmate.rb:
[root@computer ~]# ruby xmmsmate.rb
./PowerMate.rb:356: warning: don't put space before argument parentheses
./PowerMate.rb:109: warning: Object#type is deprecated; use Object#class
./PowerMate.rb:109: warning: Object#type is deprecated; use Object#class

You can disregard the output warnings, as they are only warnings, not errors.

Since the three programs only control XMMS, I opened up XMMS and found to my happy surprise, that the cool little volume knob controlled it! I could pause the playing song by holding the knob down for three seconds or forward to the next song in the playlist by holding it down longer. Sweet!

The one bummer was that these programs only allow the volume knob to control XMMS. However, I noticed if I left XMMS up and running, it could also control the volume for any PCM or waveform output. So, I am simply going to leave XMMS running all the time so that the PowerMate can control the volume for the rest of my favorite apps that output a waveform, like YouTube or Cinelerra.

Finally, I wanted the PowerMate to work automatically when my system started, so I did a few things to facilitaate this:
1) copy the three Ruby programs to /usr/bin

2) have XMMS startup automatically
You can follow these directions for starting up applications in your user profile automatically under Gnome in Fedora Core 6:

3) once your system starts, execute the driver program
ruby /usr/bin/xmmsmate.rb &

Update 1/19/2008
Unfortunately, since upgrading to Fedora 7 x86_64, I haven't been able to get my powermate to work. Looks like I will have to investigate further. Keep you posted!


No comments:

Feel free to drop me a line or ask me a question.