HOWTO: Linux (and Synaptics Touchpads) for Little Fingers

I’m not sure if this prob­lem exists with many Linux dis­tros on all lap­tops with Synap­tics touch­pads, or just Ubuntu on my Mac­book 3,1, but as shipped it has a minor issue that has prob­a­bly never reared its head for 99% of users: the touch­pad only reg­is­ters presses from adult-sized fingers.

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

The sen­si­tiv­ity of the touch­pad is defined by two val­ues, “Fin­ger­High” and “Fin­ger­Low”. These define the amount of con­tact between fin­ger and touch­pad that is required to reg­is­ter a click. There are two val­ues, High and Low, to intro­duce some hys­tere­sis — to stop a touch at just the right heav­i­ness from repeat­edly oscil­lat­ing between touch­ing and not-touching. By default, these are set to 35 (Fin­ger­High) and 29 (Fin­ger­Low) — per­fect for grown-up fin­gers, but too high (too heavy a press) for three– and four-year-olds to com­fort­ably use.

You can check the cur­rent val­ues with synclient, for example:

synclient | grep -e 'FingerHigh\|FingerLow'

You can also use synclient to exper­i­ment with dif­fer­ent val­ues. For the case of my son, I found that he was happy with Fin­ger­High set to 16 and Fin­ger­Low set to 10.

synclient FingerLow=10 && synclient FingerHigh=16

This allows a much smaller fin­ger to reg­is­ter as a touch — you can prob­a­bly test it your­self with the edge of your lit­tle fin­ger. It won’t reg­is­ter a touch at all with 35/29, but will at 16/10.

synclient is a con­ve­nient way to play around with the var­i­ous options the Synap­tics dri­ver offers, but if you’re happy with your changes, you’ll prob­a­bly want to make them per­ma­nent for all users rather than run­ning them at login for each account.

Ubuntu, along with sev­eral other dis­tros, has effec­tively dep­re­cated 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 direc­tory, and if you do, you may or may not already have a file inside it called 50-synaptics.conf. Cre­ate the direc­tory if nec­es­sary, then open the file (sub­sti­tut­ing gedit for your edi­tor 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 Fin­ger­High and Fin­ger­Low val­ues. 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 set­tings will apply every­where in X.

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

The Java Devel­op­ment Kit (JDK), which is required to write appli­ca­tions in Java, is not included by default in the Ubuntu Linux OS. Var­i­ous guides (such as this one) will give you a suc­cinct set of com­mands to run from the ter­mi­nal to down­load and install Sun’s (now Oracle’s) offi­cial JDK. But, prob­a­bly 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 Soft­ware Cen­tre, located in your Appli­ca­tions menu.  The app will open, but no mat­ter what you search for, you won’t get Sun’s JDK.  This is because it has been moved to Ubuntu’s “Part­ner” repos­i­tory, which is not enabled by default.  We will now enable it.
  2. Go to the Edit menu, and click Soft­ware Sources…
    The Ubuntu Software Centre's Edit menu
  3. You’ll be prompted to enter your pass­word, so do that:
    Password dialog
  4. In the box that appears, go to the Other Soft­ware tab.  You should see an entry on the list labelled “Canon­i­cal Part­ners”.  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 Soft­ware Cen­tre win­dow, where an “In Progress” indi­ca­tor will appear for a minute or so.  Once com­plete, you can search for “JDK” and… it still won’t show it to you.
  6. As the JDK is not some­thing that most home users want, there’s an extra obsta­cle in the way — you must ask the Soft­ware Cen­tre to show you “tech­ni­cal items”.  There’s a link at the bot­tom of the win­dow for this:
    Show Technical Items
  7. You should now have an exten­sive list of pack­ages that fea­ture the let­ters “JDK”.  You want to pick the one with the pack­age name sun-java6-jdk.  Click it, then click the Install but­ton on the right.
    Ubuntu Software Centre window with sun-java6-jre selected
  8. The JDK will now be down­loaded and installed.  Within a cou­ple of min­utes, this will be com­plete; the Install but­ton 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 any­thing else you might want from the Part­ner repos­i­tory.  The appro­pri­ate loca­tions have been added to the sys­tem path auto­mat­i­cally, but if you should need to find the JDK files man­u­ally, they’re in /usr/lib/jvm/java-6-sun-1.6.0.26 (the last sec­tion of the path may change if the lat­est JDK ver­sion is later than it was when this arti­cle was written).

HOWTO: Update ClockworkMod to flash CyanogenMod 7

Since writ­ing this arti­cle, Koush has updated ROM Man­ager to sup­port the new 3.x ver­sions of Clock­work­Mod Recov­ery. The com­plex pro­ce­dure within this guide is now unnec­es­sary for the major­ity of users, who can sim­ply flash CWM 3 through ROM Man­ager with­out requir­ing Engi­neer­ing HBOOT or any con­sole hackery.

Once again: 99% of users will NOT need to fol­low this pro­ce­dure. If you’re not sure, you are in the 99%! :)

As always, I am not respon­si­ble for any loss of data, bricked phones or global ther­monu­clear wars that result from you fol­low­ing this guide.

At the time of writ­ing (18 Jan­u­ary 2011), the lat­est ver­sion of Clock­work­Mod Recov­ery is 3.0.0.5. The lat­est ver­sion of ROM Man­ager is 3.0.0.7, and the sim­i­lar­ity between those num­bers seems to be caus­ing some con­fu­sion amongst those try­ing to install newly-released ROMs based on Gin­ger­bread. To put it simply:

  • Gin­ger­bread (Android 2.3) uses ext4 as its filesys­tem format.
  • Flash­ing a Gin­ger­bread ROM such as Cyanogen­Mod 7 cre­ates an ext4 filesys­tem on your device.
  • Once your ROM is flashed, flash­ing Google Apps requires that your Recov­ery image can write to ext4.
  • Clock­work­Mod 2.x can­not write to ext4; Clock­work­Mod 3.x can.
  • ROM Man­ager is often used to install Clock­work­Mod, how­ever, it does not list Clock­work­Mod 3.x ver­sions yet.
  • You can put Clock­work­Mod 3.0.0.5 on your device with­out touch­ing ROM Manager.
  • This guide shows you how.

The guide men­tions the HTC Desire HD (HTC Ace) specif­i­cally because that’s what I have, but it should be rea­son­ably uni­ver­sal — just Google which but­ton com­bi­na­tion gets you into HBOOT on your device, and make sure you down­load the appro­pri­ate Clock­work­Mod image for your phone.

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

If you’re still run­ning a stock ROM and haven’t yet got root or S-OFF on your device, fol­low the appro­pri­ate guide on the Cyanogen­Mod wiki. Here’s the one for the Desire HD. The Engi­neer­ing HBOOT sec­tion may be listed as optional; it is required for this process. (There are ways of flash­ing your recov­ery with only S-OFF rather than Engi­neer­ing HBOOT, but they are not cov­ered in this guide.) Once you get to “Install a Cus­tom Recov­ery Image”, ignore the wiki and fol­low this guide.

Step 2: Boot your device into FASTBOOT

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

  1. Turn off your device. (If you came straight from stock and are using HTC’s quick-boot fea­ture, you may need to remove the bat­tery for a few sec­onds to stop it quick-booting.)
  2. Boot into HBOOT. (On a Desire HD, hold down the Vol­ume Down but­ton while turn­ing your device on. This varies between devices, if you have a dif­fer­ent phone, the Cyanogen­Mod wiki will prob­a­bly tell you.) You will arrive at a coloured text menu.
  3. The top green line should men­tion “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 high­lighted, so just press the Power but­ton 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. Con­nect your phone to your com­puter via USB.

Step 3: Put the fast­boot 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 ‘fast­boot’ app (fastboot.exe, fastboot-mac or fastboot for Win/Mac/Linux respec­tively) from HTC’s site.
  3. Put the fast­boot app in your SDK’s tools folder (“C:\Android_SDK\Tools”, “~/android_sdk/tools” or wher­ever you installed it).
  4. Get the image for Clock­work­Mod 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 direc­tory along­side your fast­boot app.
  6. Open a ter­mi­nal on your com­puter and nav­i­gate 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 exe­cutable first, run chmod +x ./fastboot)
  8. Assum­ing it’s listed, run:
    fastboot flash recovery /path/to/recovery.img
    – in the case of the file we down­loaded above, if you put it in tools, the com­mand 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 fea­ture, you may need to remove the bat­tery again.)
  2. Hold down the Vol­ume Down but­ton while turn­ing 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 sec­ond, so press Vol­ume Down to high­light it, then press the Power but­ton once to go into Recovery.
  5. After the HTC logo, you’ll see your new recov­ery image up and run­ning. The menu should be orange, and the line at the top should say “Clock­work­Mod Recov­ery v3.0.0.5″.
  6. Happy flash­ing!

HOWTO: Convert WordPress Posts to Pages

I’ve recently had the unfavourable job of con­vert­ing 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 plu­gin for con­vert­ing indi­vid­ual posts to pages and back, but sadly with no bulk con­ver­sion capability.

I had a num­ber of post cat­e­gories, and I wanted all the posts in each cat­e­gory to become pages under­neath a cer­tain pre-existing page. The advan­tage with this scheme is that if the old cat­e­gory and the new par­ent page have the same name, the URL of the page doesn’t change dur­ing con­ver­sion. (e.g. a post “Suc­cess­Whale” in cat­e­gory “Soft­ware” has the URL /software/successwhale, and so does a page “Suc­cess­Whale” under­neath a par­ent page “Software”.)

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

This HOWTO is in the pub­lic domain. You are free to re-post it wher­ever and how­ever you like, though a link back here would be appreciated.

Before any­thing else, back up your data­base! I am not respon­si­ble if you break your site by fol­low­ing these instructions.

After back­ing up, I fired up MySQL Query Browser and pointed at my data­base. You could use that, or php­MyAd­min if your host pro­vides it, or even a command-line inter­face on the MySQL server if you so desire.

Back in the web browser, head to the Dash­board. We need to get two num­bers — the ID num­ber of the cat­e­gory you’re mov­ing posts from, and the ID num­ber of the par­ent page you want the new pages to sit under. For the first, pull down the Posts menu and click Cat­e­gories. On the right-hand side, hover over the “Edit” link under a cat­e­gory name.

Category Mouseover


On your sta­tus bar, you should see the loca­tion that link is point­ing to. At the end there should be a num­ber, such as the ‘14’ in this example.

Category Statusbar


To get the sec­ond num­ber, click the Pages menu on the side­bar. Just as before, hover over the Edit link of the page you want to be a parent.

Page Mouseover


And again, the sta­tus bar text will end with a num­ber, which you need to note down. Here, it’s ‘890’.

Page Statusbar


Now back to the MySQL Query Browser. Before jump­ing in with a move straight away, we should check what we’re about to move just to make sure we’ve got it right. Exe­cute the fol­low­ing query, replac­ing 14 with the first num­ber 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 pro­duce a list of the posts you want to move, and only those posts. If it does, great! Edit the fol­low­ing query, replac­ing 14 with your first num­ber from ear­lier, and 890 with the sec­ond 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")

Exe­cute that, and you should be done! Check the Posts and Pages sec­tions of the Dash­board to make sure it’s worked as you expected.

In my expe­ri­ence, the first query will some­times not return exactly what it should. In this case, I’m afraid I don’t have a clever solu­tion — this prob­lem occurred with less than half a dozen posts for me, so I just con­verted them with p2pConverter.

If you have more cat­e­gories of posts to con­vert, repeat this pro­ce­dure 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

Nor­mal XBox 360 wired con­trollers are sup­ported out of the box on Ubuntu Karmic (9.10). How­ever, it seems that dance mats such as the one that comes bun­dled with Danc­ing Stage Uni­verse behave a lit­tle dif­fer­ently. Here’s how I got mine to work.

This HOWTO is in the pub­lic domain. You are free to re-post it wher­ever and how­ever you like, though a link back here would be appreciated.

Be warned, this is not for the faint of heart — we will be spend­ing most of our time in a ter­mi­nal win­dow, and we’ll be com­pil­ing dri­vers our­selves. Read the instruc­tions care­fully, and fol­low what I did line by line. If you have prob­lems, leave a com­ment and I’ll see if I can help you out. Run­ning com­mands as the root user is poten­tially dan­ger­ous; I am not respon­si­ble if your com­puter is dam­aged by incor­rectly fol­low­ing these instructions.

First of all, check that you have the same device as I do. If not, pro­ceed only with cau­tion! To find out, plug your dance mat into a USB port, open up a ter­mi­nal win­dow 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’ num­bers will prob­a­bly be dif­fer­ent, but the rest of the line should be the same.

The xpad dri­ver, which is already baked into the ker­nel, does not work for these dance mats. We will have to instead install xbox­drv, which does sup­port dance mats.

The first thing we need to do is down­load the source code for xbox­drv. Their web­site pro­vides down­loads of var­i­ous ver­sions (at time of writ­ing, the lat­est was 0.4.10), but I chose to grab the very lat­est code from their git repos­i­tory. To do that, first install git if you don’t already have it:

sudo apt-get install git-core

Then find a space to down­load xboxdrv to — I just chose my home direc­tory, which should be the loca­tion you’re at when you first run the ter­mi­nal any­way. Down­load their lat­est source using git, then go into the down­loaded directory:

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

Now you’ll need to com­pile the dri­ver from the source code you’ve just down­loaded. These fol­low­ing instruc­tions are largely from the README file included with xboxdrv. You’ll need a bunch of things installed so that you can com­pile the code. To make sure you have every­thing, run:

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

Now com­pile by sim­ply running:

scons

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

Assum­ing you don’t see any errors, you now have a dri­ver that will sup­port the dance mat. How­ever, this is a ‘user-space’ dri­ver, which means we don’t actu­ally bake it into the ker­nel — instead, we need to make sure that the ker­nel sup­ports user-space input dri­vers, then we run xboxdrv as if it were a nor­mal application.

First of all, though, we should check it’s actu­ally work­ing. To start with, we’ll remove the xpad dri­ver from the ker­nel, and add the user-space dri­ver sup­port. Note that if you have any other joy­sticks, remov­ing xpad could stop them work­ing. I’m not sure if there’s any way around this at the moment. Run the fol­low­ing commands:

sudo rmmod xpad
sudo modprobe uinput
sudo modprobe joydev

Now we can run xboxdrv and check it’s work­ing. Type:

sudo ./xboxdrv

You should see some­thing 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 appear­ing at the end indi­cat­ing the but­tons that have been pressed. The arrows on the mat match up to D-pad direc­tions, so for exam­ple if you press Down, you should see dd:1 on the line that appears.

Once you’re sat­is­fied that it’s work­ing, hit Ctrl+C to quit.

Before we’re fin­ished, we need to make those changes to the ker­nel mod­ules per­ma­nent. 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 ker­nel mod­ule changes will stick.

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

First, let’s put xboxdrv some­where sen­si­ble on your filesys­tem, 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 past­ing it here, here’s a down­load link instead: xbox­drv init script. Down­load this, then copy it to /etc/init.d. That requires root access, so from your ter­mi­nal, run the fol­low­ing to down­load 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 exe­cutable and that it runs on startup:

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

(don’t for­get the dot on the end!)

Aaaand at long last, you should be done. Reboot, and your dance mat should work prop­erly with no extra con­fig­u­ra­tion. If you’re using Step­Ma­nia, remem­ber to map the mat’s con­trols before play­ing. If you’ve not drunk that cup of tea yet, it’s prob­a­bly cold!

If you’re look­ing for a sim­i­lar guide for Open­SuSE, I’ve just dis­cov­ered this post which is sim­i­lar to the post you’re read­ing, but with OpenSuSE-specific init script instructions.