Disclaimer: This post only describes what I’ve been hacking on those days, and why. I haven’t finished yet, and that might be too long of a story for a blog/planet. I’m therefore duplicating the problem and the context, and mentioning the parts already documented on the page dedicated to that hack.

Challenge: How to send commands to a computer without using an input device?

Context: While it’s not frequent, I sometimes run into situations where no input devices would work. That can happen because of a new X server with no compatible input devices; or while running a sample Wayland compositor on a console with X still running (not exactly sure what the problem was exactly); or because running gdb on X from within X is a bad idea; etc.

Simple, non-bulletproof solutions:

  • Obviously, sshing from another machine is the ideal situation. But that requires an extra machine, which might not be available during a train trip.
  • Using a smartphone to do that would be nice, but would require buying such a phone.
  • Having an extra input device, with an appropriate X configuration (i.e. not taking that input device into account) could also work. But that wouldn’t really help with some weird situations involving console, Wayland compositor, and X.

Alternative, viable solution 1:

Buying a tiny, open, programmable device, like the Arduino Nano, a few components like a selector and a push button might do the trick. Then, some bits of programming with the open source Arduino environment should make it possible to connect that device to a USB port using a mini-B cable. Some bits going through a serial console and a daemon listening on it would make it possible to trigger a predefined set of actions just by selecting a position and hitting the button. Tada!

No drawback for that solution, except the need for thinking about bringing that device everywhere. :)

Alternative, viable solution 2:

While I’m by no means a phone addict, I tend to have it with me more or less all the time, and it can be connected through a mini-B USB cable. Oh, but then, maybe I could turn it into a suitable device as described above?

That’s a Motorola RAZR V3, it runs Java applications, and there’s a SDK available for Linux (32 bits) through the Motorola developer network. That might be enough, so I decided to jump through some hoops to see whether that’s indeed feasible. Not because I like it much better than the Arduino-based solution, just because I can.

My hack’orola page explains how I went from the “maybe it’s possible” idea to the “yes, now I know how to build, upload, and run a custom application” certitude. It still lacks the actual Java code running on the phone, as well as its Unix daemon counterpart, but for a good reason: they need be written!

At the moment the following sections are available:

  • Step 1: Enabling Java Application Loader
  • Step 2: Getting the SDK
  • Step 3: Toying with a trivial project
  • Step 4: Getting ready to deploy