evdev for ruby (with morse code!)

I built a ruby wrapper for the linux evdev interface. evdev is an interface that lets you work with various linux input devices – touchscreens and mouses and joysticks and keyboards.

So what can you do with this?

  • Well, you can map the interesting (yet unused) buttons on your keyboards and mice to ruby functions. Even those crazy buttons like volume up and down are fair game
  • If you are the sort of person who can never have too many buttons, you could even attach an additional usb keyboard and have 100+ additional ruby programmable keys to play with (this would require just a tiny bit of xorg.conf playing…but ask me an I’ll explain it).
  • You can control your keyboard LEDs and have them flash when interesting events occur (like mail, or when you’re missing a meeting)

I’ve written one sample app. It takes data on STDIN and outputs to your scroll lock LED in morse code. Just like in Cryptonomicon!

fancy documentation
the code itself
a tarball
morse sample documentation

Note that because this has a c extension in it, you’ll have to recompile it on your linux system. It’s super easy. Go to the root and type “ruby extconf.rb”…this will generate a Makefile. Then type “make” and you should be good to go.

Update! If you want to make this comptable with Ruby 2, use this very nice patch file by Scott Johnson


  1. Benjamin Bernard says:

    very very cool of course. I, like Mike, found it extremely interesting to learn that you can set the lights on the keyboard, and they aren’t even related to what they are supposed to be related to!

    Now if only I could get it going on the mac….

  2. buffalo says:

    Well, there is this cross-platform library called libusb which might be an even better canidate for ruby binding. After I finish my USB device hacking, it might be worthwhile to write a ruby interface to that too.

  3. […] to listen to. (In my case it’s a Nostromo Speedpad N50). The implementation underneath uses evdev for ruby by […]

  4. Scott Johnson says:

    Any chance this could be updated to support Ruby 2.0.0? (I get several compile errors.)

Leave a Reply