HOWTO: Linux (and Synaptics Touchpads) for Little Fingers

I’m not sure if this problem exists with many Linux distros on all laptops with Synaptics touchpads, or just Ubuntu on my Macbook 3,1, but as shipped it has a minor issue that has probably never reared its head for 99% of users: the touchpad only registers presses from adult-sized fingers.

Although my son has long since figured out how to say “screw that” and reboot into Mac OS, I figured I should have a crack at fixing the problem.

The sensitivity of the touchpad is defined by two values, “FingerHigh” and “FingerLow”. These define the amount of contact between finger and touchpad that is required to register a click. There are two values, High and Low, to introduce some hysteresis — to stop a touch at just the right heaviness from repeatedly oscillating between touching and not-touching. By default, these are set to 35 (FingerHigh) and 29 (FingerLow) — perfect for grown-up fingers, but too high (too heavy a press) for three- and four-year-olds to comfortably use.

You can check the current values with synclient, for example:

synclient | grep -e 'FingerHigh\|FingerLow'

You can also use synclient to experiment with different values. For the case of my son, I found that he was happy with FingerHigh set to 16 and FingerLow set to 10.

synclient FingerLow=10 && synclient FingerHigh=16

This allows a much smaller finger to register as a touch — you can probably test it yourself with the edge of your little finger. It won’t register a touch at all with 35/29, but will at 16/10.

synclient is a convenient way to play around with the various options the Synaptics driver offers, but if you’re happy with your changes, you’ll probably want to make them permanent for all users rather than running them at login for each account.

Ubuntu, along with several other distros, has effectively deprecated the use of xorg.conf in favour of device-specific scripts inside /usr/share/X11/xorg.conf.d. You may or may not have this directory, and if you do, you may or may not already have a file inside it called 50-synaptics.conf. Create the directory if necessary, then open the file (substituting gedit for your editor of choice):

sudo mkdir /usr/share/X11/xorg.conf.d
sudo gedit /usr/share/X11/xorg.conf.d/50-synaptics.conf

Edit the file to include Option lines that set your desired FingerHigh and FingerLow values. Mine looks like this:

Section "InputClass"
        Identifier "touchpad catchall"
        Driver "synaptics"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Option "FingerLow" "10"
        Option "FingerHigh" "16"
EndSection

Save the file, and when you restart, your new settings will apply everywhere in X.

HOWTO: Install Sun’s JDK on Ubuntu (without the Command Line)

The Java Development Kit (JDK), which is required to write applications in Java, is not included by default in the Ubuntu Linux OS. Various guides (such as this one) will give you a succinct set of commands to run from the terminal to download and install Sun’s (now Oracle’s) official JDK. But, probably because it’s harder to explain, none show you the slightly more user-friendly point-and-click way of doing it. Well, this page does.

  1. Open the Ubuntu Software Centre, located in your Applications menu.  The app will open, but no matter what you search for, you won’t get Sun’s JDK.  This is because it has been moved to Ubuntu’s “Partner” repository, which is not enabled by default.  We will now enable it.
  2. Go to the Edit menu, and click Software Sources…
    The Ubuntu Software Centre's Edit menu
  3. You’ll be prompted to enter your password, so do that:
    Password dialog
  4. In the box that appears, go to the Other Software tab.  You should see an entry on the list labelled “Canonical Partners”.  Check the box at the left of that entry, then click Close.
    Software Sources window
  5. You will now be returned to the main Ubuntu Software Centre window, where an “In Progress” indicator will appear for a minute or so.  Once complete, you can search for “JDK” and… it still won’t show it to you.
  6. As the JDK is not something that most home users want, there’s an extra obstacle in the way — you must ask the Software Centre to show you “technical items”.  There’s a link at the bottom of the window for this:
    Show Technical Items
  7. You should now have an extensive list of packages that feature the letters “JDK”.  You want to pick the one with the package name sun-java6-jdk.  Click it, then click the Install button on the right.
    Ubuntu Software Centre window with sun-java6-jre selected
  8. The JDK will now be downloaded and installed.  Within a couple of minutes, this will be complete; the Install button will change to say Remove and the icon next to sun-java6-jre will show a green tick.

Sun’s JDK is now installed.  You can now search for and install Sun’s JRE, and anything else you might want from the Partner repository.  The appropriate locations have been added to the system path automatically, but if you should need to find the JDK files manually, they’re in /usr/lib/jvm/java-6-sun-1.6.0.26 (the last section of the path may change if the latest JDK version is later than it was when this article was written).

The UI of Least Resistance

I was working up to a blog post on Ubuntu‘s new “Unity” interface a couple of days ago, but repeatedly stalled when it came to making a point. The only point I could come up with was essentially just “I don’t like this”, which isn’t the greatest of subjects for a blog post — to say nothing of the hundreds who have trodden that territory before me.

Ubuntu's Unity interface

Ubuntu's Unity interface (image credit: webupd8.org)

It’s a fairly bold new direction for Ubuntu’s UI, and the first time their default interface has really diverged from what the upstream GNOME project provides. Now I don’t like it for a number of reasons: it’s slow, it doesn’t provide some basic functionality, other functionality is really well hidden (Go on, re-order your icons. Try it.) and it’s got an “our way or nothing” approach to handling workspaces.

On one hand, as a software guy whose main specialisation is user interface design, I understand the urge to try new UI paradigms as often as possible, on the grounds that sooner or later you’ll discover something that really is better than what you currently have. On the other hand, I quietly despair at how far off that “something better” seems.

Take, for example, me. I’m a UX person, and a perfectionist when it comes to interfaces. I’m irritated by slightly-wrong fonts and icons a couple of pixels out of alignment. I love new things, new ways of organising and displaying data. I’m big on augmented reality. And my desktop looks like this:

Bare XFCE Desktop

Now I think that’s aesthetically pleasing, but in terms of functionality, it resembles nothing quite so much as:

Windows 95 Desktop

Yeah, that.

The only notable exception is GNOME-Do (think Launchy on Windows or Quicksilver on OS X), which I use exclusively for launching apps. The main menu, lower left, only gets used if I forget the name of something. Aside from that, I’m using my computer in exactly the same way I was 16 years ago.

The reason for that, as far as I can tell, is that it is the UI of least resistance. In sixteen years, probably 99% of my computer-using time has involved an interface that’s very similar to that one. Sure, there are certainly better UIs out there. Maybe from an objective point of view, Unity is one of them. But for more than half of my life, my brain has been slowly optimising itself for the Windows 95 style interface.

To become the “next big thing” in desktop UI, a new paradigm must not only be better than what came before, it must be so much better that our brains don’t mind losing half a lifetime’s worth of learning.

That’s a milestone I haven’t seen reached lately on the desktop, and a fear we may not see it reached before “the desktop” stops being a thing.

HOWTO: Use an XBox 360 Dance Mat on Ubuntu Karmic

Normal XBox 360 wired controllers are supported out of the box on Ubuntu Karmic (9.10). However, it seems that dance mats such as the one that comes bundled with Dancing Stage Universe behave a little differently. Here’s how I got mine to work.

This HOWTO is in the public domain. You are free to re-post it wherever and however you like, though a link back here would be appreciated.

Be warned, this is not for the faint of heart — we will be spending most of our time in a terminal window, and we’ll be compiling drivers ourselves. Read the instructions carefully, and follow what I did line by line. If you have problems, leave a comment and I’ll see if I can help you out. Running commands as the root user is potentially dangerous; I am not responsible if your computer is damaged by incorrectly following these instructions.

First of all, check that you have the same device as I do. If not, proceed only with caution! To find out, plug your dance mat into a USB port, open up a terminal window and run

lsusb

You should see a line which looks like:

Bus 002 Device 002: ID 12ab:0004 Honey Bee Electronic International Ltd.

Your ‘Bus’ and ‘Device’ numbers will probably be different, but the rest of the line should be the same.

The xpad driver, which is already baked into the kernel, does not work for these dance mats. We will have to instead install xboxdrv, which does support dance mats.

The first thing we need to do is download the source code for xboxdrv. Their website provides downloads of various versions (at time of writing, the latest was 0.4.10), but I chose to grab the very latest code from their git repository. To do that, first install git if you don’t already have it:

sudo apt-get install git-core

Then find a space to download xboxdrv to — I just chose my home directory, which should be the location you’re at when you first run the terminal anyway. Download their latest source using git, then go into the downloaded directory:

git clone git://github.com/Grumbel/xboxdrv.git
cd xboxdrv

Now you’ll need to compile the driver from the source code you’ve just downloaded. These following instructions are largely from the README file included with xboxdrv. You’ll need a bunch of things installed so that you can compile the code. To make sure you have everything, run:

sudo apt-get install g++ libboost1.40-dev libboost-thread1.40-dev scons libusb-dev libx11-dev x11proto-core-dev python-dbus

Now compile by simply running:

scons

Make a cup of tea, this will take a few minutes.

Assuming you don’t see any errors, you now have a driver that will support the dance mat. However, this is a ‘user-space’ driver, which means we don’t actually bake it into the kernel — instead, we need to make sure that the kernel supports user-space input drivers, then we run xboxdrv as if it were a normal application.

First of all, though, we should check it’s actually working. To start with, we’ll remove the xpad driver from the kernel, and add the user-space driver support. Note that if you have any other joysticks, removing xpad could stop them working. I’m not sure if there’s any way around this at the moment. Run the following commands:

sudo rmmod xpad
sudo modprobe uinput
sudo modprobe joydev

Now we can run xboxdrv and check it’s working. Type:

sudo ./xboxdrv

You should see something like the following:

xboxdrv 0.4.8
Copyright (C) 2008 Ingo Ruhnke <grumbel@gmx.de>
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
 
USB Device:        002:002
Controller:        "DDR Universe 2 Mat" (idVendor: 0x12ab, idProduct: 0x0004)
Controller Type:   Xbox360
Deadzone:          0
Trigger Deadzone:  0
Rumble Debug:      off
Rumble Speed:      left: -1 right: -1
LED Status:        auto
Square Axis:       no
ButtonMap:         none
AxisMap:           none
RelativeAxisMap:   none
AutoFireMap:       none
RumbleGain:        255
ForceFeedback:     disabled
 
Starting with uinput... Error: /dev/input/uinput: No such file or directory
done
 
Your Xbox/Xbox360 controller should now be available as:
  /dev/input/js0
  /dev/input/event7
 
Press Ctrl-c to quit
 
X1:     0 Y1:     0  X2:     0 Y2:     0  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0
TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0

(You can ignore the “Error: /dev/input/uinput: No such file or directory” line if it appears on your screen, it doesn’t seem to affect xboxdrv at all.)

Press some of the pads on your dance mat. You should see extra lines appearing at the end indicating the buttons that have been pressed. The arrows on the mat match up to D-pad directions, so for example if you press Down, you should see dd:1 on the line that appears.

Once you’re satisfied that it’s working, hit Ctrl+C to quit.

Before we’re finished, we need to make those changes to the kernel modules permanent. To do this, run:

sudo -i
echo "blacklist xpad" >> /etc/modprobe.d/blacklist.conf
echo "uinput" >> /etc/modules
echo "joydev" >> /etc/modules
exit

You can now reboot if you want to, and all your kernel module changes will stick.

There’s one more step. At the moment before using your dance mat, you’ll still have to run xboxdrv manually. We can fix this with an ‘init script’ that will run xboxdrv automatically on startup.

First, let’s put xboxdrv somewhere sensible on your filesystem, rather than in your home directory:

sudo mkdir /usr/local/bin/xboxdrv
sudo cp xboxdrv /usr/local/bin/xboxdrv/xboxdrv
sudo cp tools/xboxdrv-daemon.py /usr/local/bin/xboxdrv/xboxdrv-daemon.py

Now we’ll set up the init script. The script itself is a few dozen lines, so rather than pasting it here, here’s a download link instead: xboxdrv init script. Download this, then copy it to /etc/init.d. That requires root access, so from your terminal, run the following to download the above file and put it in the right place:

cd ~
wget http://www.onlydreaming.net/files/xboxdrv
sudo mv xboxdrv /etc/init.d/xboxdrv

Now we have to make sure that’s executable and that it runs on startup:

sudo chmod +x /etc/init.d/xboxdrv
sudo update-rc.d xboxdrv start 51 S .

(don’t forget the dot on the end!)

Aaaand at long last, you should be done. Reboot, and your dance mat should work properly with no extra configuration. If you’re using StepMania, remember to map the mat’s controls before playing. If you’ve not drunk that cup of tea yet, it’s probably cold!

If you’re looking for a similar guide for OpenSuSE, I’ve just discovered this post which is similar to the post you’re reading, but with OpenSuSE-specific init script instructions.

All Bugs Are Shallow… Except This One

In his essay “The Cathedral and the Bazaar”, Eric S. Raymond coins the phrase “given enough eyeballs, all bugs are shallow” — meaning that with enough testers and enough programmers, it is possible to diagnose and fix any software bug.

So why can’t my computer suspend and resume properly?

The concept of ‘suspend’ — or ‘sleep’, or ‘standby’ — mode, whereby the computer dumps its internal state to RAM then enters a low-power state with its processor and other hardware turned off, is not new. The ACPI standard has been kicking around for 14 years now, a very long time compared to the life cycle of an operating system. These days, with laptop use on the rise, it’s a very common thing for users to want to do. And yet resuming from suspend is still hit-and-miss.

Why do I find it more reliable in Ubuntu than openSUSE for the same base kernel? Why does GNOME fare better than KDE? Why does my WiFi sometimes not come back? Why, with Microsoft’s million- if not billion-dollar operating system budgets, with Intel and AMD and nVidia’s decades’ of driver experience, is suspend and resume still frequently an issue even on Windows?

Only Apple, with its closed hardware / software ecosystem, seems to have cracked it.

I’d hate to think of that as the only way to a bug-free existence — I’m very fond of the idea of an open ecosystem where I can run whatever software I want on whatever hardware I want. But I’m worried. Is the range of (IBM-compatible, ACPI-supporting) hardware out there just too diverse and too widely different in its support for suspend-and-resume? Is it just infeasible for software to perfectly implement it on all devices?

Has hardware created the one software bug that, for any reasonable number of eyeballs, isn’t shallow?