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).

HOWTO: Update ClockworkMod to flash CyanogenMod 7

Since writing this article, Koush has updated ROM Manager to support the new 3.x versions of ClockworkMod Recovery. The complex procedure within this guide is now unnecessary for the majority of users, who can simply flash CWM 3 through ROM Manager without requiring Engineering HBOOT or any console hackery.

Once again: 99% of users will NOT need to follow this procedure. If you’re not sure, you are in the 99%! :)

As always, I am not responsible for any loss of data, bricked phones or global thermonuclear wars that result from you following this guide.

At the time of writing (18 January 2011), the latest version of ClockworkMod Recovery is 3.0.0.5. The latest version of ROM Manager is 3.0.0.7, and the similarity between those numbers seems to be causing some confusion amongst those trying to install newly-released ROMs based on Gingerbread. To put it simply:

  • Gingerbread (Android 2.3) uses ext4 as its filesystem format.
  • Flashing a Gingerbread ROM such as CyanogenMod 7 creates an ext4 filesystem on your device.
  • Once your ROM is flashed, flashing Google Apps requires that your Recovery image can write to ext4.
  • ClockworkMod 2.x cannot write to ext4; ClockworkMod 3.x can.
  • ROM Manager is often used to install ClockworkMod, however, it does not list ClockworkMod 3.x versions yet.
  • You can put ClockworkMod 3.0.0.5 on your device without touching ROM Manager.
  • This guide shows you how.

The guide mentions the HTC Desire HD (HTC Ace) specifically because that’s what I have, but it should be reasonably universal – just Google which button combination gets you into HBOOT on your device, and make sure you download the appropriate ClockworkMod image for your phone.

Step 1: Get root and S-OFF if you haven’t already

If you’re still running a stock ROM and haven’t yet got root or S-OFF on your device, follow the appropriate guide on the CyanogenMod wiki. Here’s the one for the Desire HD. The Engineering HBOOT section may be listed as optional; it is required for this process. (There are ways of flashing your recovery with only S-OFF rather than Engineering HBOOT, but they are not covered in this guide.) Once you get to “Install a Custom Recovery Image”, ignore the wiki and follow this guide.

Step 2: Boot your device into FASTBOOT

Your device must be in FASTBOOT mode to accept a new Recovery image. For the Desire HD:

  1. Turn off your device. (If you came straight from stock and are using HTC’s quick-boot feature, you may need to remove the battery for a few seconds to stop it quick-booting.)
  2. Boot into HBOOT. (On a Desire HD, hold down the Volume Down button while turning your device on. This varies between devices, if you have a different phone, the CyanogenMod wiki will probably tell you.) You will arrive at a coloured text menu.
  3. The top green line should mention “S-OFF”, if it doesn’t, go back to Step 1 and try again.
  4. The first white-on-blue line says “HBOOT”. You’re in HBOOT mode.
  5. The coloured items are a menu, which the orange text tells you how to use. “FASTBOOT” is first and is already highlighted, so just press the Power button once to go into FASTBOOT.
  6. The white-on-blue “HBOOT” should now have changed into a white-on-red “FASTBOOT”. You’re in FASTBOOT mode.
  7. Connect your phone to your computer via USB.

Step 3: Put the fastboot app on your computer

  1. If you don’t have the Android SDK, grab it from Google’s site and install it.
  2. Get the ‘fastboot’ app (fastboot.exe, fastboot-mac or fastboot for Win/Mac/Linux respectively) from HTC’s site.
  3. Put the fastboot app in your SDK’s tools folder (“C:\Android_SDK\Tools“, “~/android_sdk/tools” or wherever you installed it).
  4. Get the image for ClockworkMod 3.0.0.5 from crackflashers.com (thanks gridlock32404). Here’s a direct link to the Desire HD (“Ace”) image.
  5. Put that file in the tools directory alongside your fastboot app.
  6. Open a terminal on your computer and navigate to the tools directory.
  7. Run fastboot devices to check your phone is listed. (fastboot-mac devices on Mac. On Linux you may need to make fastboot executable first, run chmod +x ./fastboot)
  8. Assuming it’s listed, run:
    fastboot flash recovery /path/to/recovery.img
    – in the case of the file we downloaded above, if you put it in tools, the command becomes
    fastboot flash recovery ./ace-cwm3src3.0.0.5-1-15-11.img
  9. Run fastboot reboot

Step 4: Boot into your new recovery!

  1. Turn off your device. (If you’re still using HTC’s quick-boot feature, you may need to remove the battery again.)
  2. Hold down the Volume Down button while turning your device on. You will arrive at a coloured text menu.
  3. The first white-on-blue line says “HBOOT”. You’re in HBOOT mode.
  4. The coloured items are a menu, which the orange text tells you how to use. “RECOVERY” is second, so press Volume Down to highlight it, then press the Power button once to go into Recovery.
  5. After the HTC logo, you’ll see your new recovery image up and running. The menu should be orange, and the line at the top should say “ClockworkMod Recovery v3.0.0.5″.
  6. Happy flashing!

HOWTO: Convert WordPress Posts to Pages

I’ve recently had the unfavourable job of converting some 400 posts on my WordPress-powered site into pages. I’d been putting this off for a while, as as far as I could see the only sane way of doing this was using p2pConverter — a great plugin for converting individual posts to pages and back, but sadly with no bulk conversion capability.

I had a number of post categories, and I wanted all the posts in each category to become pages underneath a certain pre-existing page. The advantage with this scheme is that if the old category and the new parent page have the same name, the URL of the page doesn’t change during conversion. (e.g. a post “SuccessWhale” in category “Software” has the URL /software/successwhale, and so does a page “SuccessWhale” underneath a parent page “Software”.)

In the end, I wrangled some SQL to do the job. This is how I did it.

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.

Before anything else, back up your database! I am not responsible if you break your site by following these instructions.

After backing up, I fired up MySQL Query Browser and pointed at my database. You could use that, or phpMyAdmin if your host provides it, or even a command-line interface on the MySQL server if you so desire.

Back in the web browser, head to the Dashboard. We need to get two numbers — the ID number of the category you’re moving posts from, and the ID number of the parent page you want the new pages to sit under. For the first, pull down the Posts menu and click Categories. On the right-hand side, hover over the “Edit” link under a category name.

Category Mouseover


On your status bar, you should see the location that link is pointing to. At the end there should be a number, such as the ’14′ in this example.

Category Statusbar


To get the second number, click the Pages menu on the sidebar. Just as before, hover over the Edit link of the page you want to be a parent.

Page Mouseover


And again, the status bar text will end with a number, which you need to note down. Here, it’s ’890′.

Page Statusbar


Now back to the MySQL Query Browser. Before jumping in with a move straight away, we should check what we’re about to move just to make sure we’ve got it right. Execute the following query, replacing 14 with the first number you obtained earlier:

SELECT *
FROM wp_posts, wp_term_relationships
WHERE (wp_posts.id = wp_term_relationships.object_id)
AND (wp_term_relationships.term_taxonomy_id = 14)
AND (wp_posts.post_type = "post");

This should produce a list of the posts you want to move, and only those posts. If it does, great! Edit the following query, replacing 14 with your first number from earlier, and 890 with the second number:

UPDATE wp_posts, wp_term_relationships
SET wp_posts.post_type = "page",
wp_posts.post_parent = 890
WHERE (wp_posts.id = wp_term_relationships.object_id)
AND (wp_term_relationships.term_taxonomy_id = 14)
AND (wp_posts.post_type = "post")

Execute that, and you should be done! Check the Posts and Pages sections of the Dashboard to make sure it’s worked as you expected.

In my experience, the first query will sometimes not return exactly what it should. In this case, I’m afraid I don’t have a clever solution — this problem occurred with less than half a dozen posts for me, so I just converted them with p2pConverter.

If you have more categories of posts to convert, repeat this procedure again until you’ve got them all done.

I hope you’ve found this useful!

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.