HDAPS on Thinkpad

Its a common knowledge that Thinkpads have HDAPS feature (IBM Active Protection System). Its primary purpose, in Windows at least, is to detect falling motion (laptop about to crash into the ground) so that it can immediately park the hard disk heads to prevent data loss. How cool is that?
In Linux, are are available drivers that you can install in order for you to make use or access the built-in accelerometer. Users on YouTube have already posted demos of fun things you can do with it, from useful features such as tapping your laptop to switch workspaces, or changing the display orientation to silly ones like playing games by tilting the laptop itself and making it hum like Jedi swords. So what do you need to get started hacking? First, you’ll need the TP_SMAPI. Second? Imagination. Here’s a java port to get you started:

int threshold = 2;
long numMillisecondsToSleep = 1000; // 1 second
int oldx=0, oldy=0, x, y;
boolean doupdate;

try {
    do {
        FileReader fr = new FileReader("/sys/devices/platform/hdaps/position");
        BufferedReader br = new BufferedReader(fr);
        String s = br.readLine();

        StringTokenizer st = new StringTokenizer(s, "(,)");
        x = Integer.parseInt(st.nextToken());
        y = Integer.parseInt(st.nextToken());

        doupdate = false;

        if ((oldx != x) || (oldy != y)) {

            if (Math.abs(oldx - x) > threshold) {
                oldx = (oldx != x) ? x : oldx;
                doupdate = true;

            if (Math.abs(oldy - y) > threshold) {
                oldy = (oldy != y) ? y : oldy;
                doupdate = true;

            if (doupdate) {
                System.out.println("x = " + oldx + " | " + "y = " + oldy);


        try {
        } catch (InterruptedException e) {
    } while(true);

} catch (IOException e) {

Ported from the original C code written by Jeff Molofee.

I have been using Linux since 1996 and started with Slackware v1 and FreeBSD but I have never used linux on any of my PCs. Today, I have made the jump from Windows to Linux last month after buying a used Lenovo Thinkpad x60. I opted to use PCLinuxOS due to its rave reviews and growing popularity. Recently, it surpassed Ubuntu on the number of downloads based on Distrowatch stats. Based on my experience with Ubuntu and PCLinuxOS, I think Linux is finally ready on the desktop.

Almost everything works with PCLinuxOS2007 except for the IBM Action Protection System due to lack of available Linux drivers. Installation was smooth and never encountered problems (make sure you dont have any other programs running when you hit “install to hard disk”. I used a bootable USB drive since this model doesnt come with a CD/DVD drive. Ethernet, Bluetooth, Wifi, SD memory slot, USB, Sound, and Mic works perfectly. Can detect inserted drives and easily detects wifi and lan. My unit doesnt have the fingerprint feature.

Thinkpad x60


Processor Intel Core 2 Dou processor T5600 (1.8GHz)
Memory 2GB DDR2-667
Hard drive Toshiba 100GB 5400RPM SATA
Display 12.1″ TFT display
Graphics Intel Graphics Media Accelerator 950
Wireless Intel 3945 802.11a/b/g wireless, IBM Bluetooth 2.0
Networking Intel Pro/1000 Gigabit Ethernet
Expansion 3 USB 2.0 ports, 1 4-pin Firewire (IEEE 1394) port, 1 Express Card, 1 Secure Digital
Battery Lithium Ion 8 cell


* If you dont have CD/DVD drive, you only need a USB drive and ISO CD Image to install. Follow the instructions here if you are on Linux, or here if you are on Windows,
* If you have at least 2Gb RAM, allocate a maximum of 1Gb or even less for Swap space. You will hardly use it.
* To enable Thinkpad function buttons (Blue buttons), enable the KMilo plugin under KDE Control Center | System Administration.
* Default video players didnt work on my fresh install. Had to Install VLC to watch avi files (tv shows for my case)
* Additional Thinkpad-specific apps that you can install are: KThinkBat for better battery power usage detection and TP_SMAPI (HDAPS driver for the built-in accelerometer).
* You can enable the frequency scaling feature by enabling the “powernowd” service at PCLOS Control Center | System | Enable or disable system services.
* With the latest Wine version, you can still enjoy Windows apps like Photosop 7, Dreamweaver 8, Microsoft Office 2003 and Warcraft 3 – TFT as they can run on Linux w/o a hitch.

Known problems and solutions:

Solved: Sound doesnt work by default.
Solution: Upgrade kernel to kernel- or higher
Explanation: ALSA related bug in kernel

Solved: Fn + Home (Increase Brightness) will blank your screen
Solution: edit the /etc/modprobe.conf and add the line “alias video off” (The blacklist solution doesnt work.)
Explanation: There is a conflict with the ACPI video module.

Solved: Sending files to Bluetooth devices via GUI.
Solution: Install kbluetooth
Explanation: Not installed by default

What doesnt work:

* FN+F7, FN+F8, FN+F9.


* Express Card slot
* 56K Modem
* Infrared

The obligatory screenshot:

PCLOS2007 on Thinkpad x60

Flex 2 Books

Very Exciting weekend :). Why? its because the Flex 2 books and Training Videos I ordered last week just arrived yesterday!. I wont be mentioning all the titles yet but so far from what I’ve seen and read, the Lynda.com : Flex 2 Advanced: Using Data Services Training Video is excellent stuff! I went thru chapter 3 to 9 (Im semi-advanced student ;P) and all I can say is, the money spent was all worth it. I’m now consuming the Adobe Flex & Java book from the guys at Farata Systems. Im deep-diving on the data-integration stuff since its going to be the most crucial part of our enterprise application development. Will update on the book reviews as soon as I’ve covered some chapters. Right now I’m looking at how to replace or redesign our existing ACEGI-based security module.

Update: June 28, 2007

Disclaimer: I haven’t read the whole book yet but here’s my first impressions from the few chapters Ive read and jumping from one chapter to another. The Adobe Flex & Java book: RIA Book was good but was kinda outdated. It featured a lot of working real-world examples which is good stuff. The books weren’t cheap so I was a little disappointed because I was expecting more of advanced Flex-Java stuff that takes on advanced custom component tricks/hacks, a bit of Cairngorm or other MVC frameworks, Modules, Security / ACLs, Migrating from web frameworks to pure Flex front-end. I was also looking for a bit about Spring integration or anything about a guide for former AJAX developers (for some who have been doing web apps all their lives, switching to event-based app is a paradigm shift). The ebook that came with the book is useless. Table of contents is unclickable and unsearchable. I am yet to check out the bundled Training Video.

I also have the Actionscript 3 Cookboook from Oreilly. This book is excellent! I’ve read 3 whole chapters so far: XML, Arrays and Menus and I’m already smiling from ear to ear from what I’ve absorbed so quickly. I just realized how powerful E4X support is!!! and how AS3 easily handles XML data like a fish to a water. Highly recommended even for someone like me who never programmed in Actionscript before.

I also have Adobe Flex: Straight from the source and Oreilly Flex 2 Programming. Just browsed thru the pages and jumping from diff chapters . They are almost the same. Just a little better than the official Flex2 documentation which is available for free in PDF form. In fairness, the two books covered more examples than the official doc.

I also have Flex 2 Total Training training video. It covers how to use Flex builder and working with Flex 2 UI components. No advanced stuff. haven’t watched them all yet so I cant comment much.

Too much many books, too little time.

Just finished cleaning up some slides I used for my Team’s training. Here it is:

Quick guide on Integrating Flex 2, LiveCycle Data Services and Spring – For Java developers who wants to integrate Flex with new or existing J2EE applications.
Cairngorm Microarchitecture
– Advanced topic not meant for Flex/Actionscript beginners. Read this before taking on Cairngorm.
Flex Modules – Created by Alex Harui. Very useful for building big Flex 2 apps. Modules are used to break applications up into smaller pieces.

Flex 2 Slides

I’ve been reading tons of materials about Flex 2 and Cairngorm framework the past few weeks since May. Me and my team are looking at replacing the Struts v1 front-end of one of our flagship product (a Certified, standards-compliant web app for Healthcare industry). After studying the alternatives, client’s requirements, feedbacks, and expert opinions, I have decided that RIA with Flex 2 is the way to go. We are now gearing towards ASP model all the way. I have prepared and “borrowed” bits and parts of contents from other slides publicly available on the net and aggregated all the good stuff into one presentation file. To the original authors, pls. forgive me :). I created this for my team and want to share the information back to the community. This slide is going to be my first installment on Flex category. Expect a lot more once I’ve cleaned up stuff on other slides. I’m also uploading my RSS feeds (OPML) for all Flex 2 related blogs I’m subscribed to. (so you don’t have to hunt for them one by one!)

Introduction to Flex 2 – Beginners guide to Flex 2 framework
My Flex 2 RSS Feeds – My collection of RSS feeds related to Flex 2. Rename it to .opml extension and import it to your favorite RSS reader. I’d like to recommend Omea Reader (it’s free!).

If you are also interested to study Flex 2, I’d like to recommend the ff links below: