[Linux] Playing With Thinkpad Special Buttons

I am using a T60 laptop, the one without a fingerprint reader.  The 4 special buttons on the top left corner of the keyword are mute, volume up, volume down and ThinkVantage. The Window version came preinstalled with a program that displays a volume bar whenever any one of the volume controlling buttons is pressed. Unfortunately in a M$ dominated world, this program does not have a Linux version. There are applications that provide similar functionality, but I have decided to write a script myself.

Playing With Volume Buttons

ACPI (Advanced Configuration and Power Interface) is a wonderful standard, it makes programming devices easier. In Linux, information for some of the devices is made available in /proc/acpi/ibm/ folder. A simple cat /proc/acpi/ibm/volume tells you whether the speaker is muted, and the volume level (on a scale of 0 ~ 14).

I wrote the following script to display the volume level:

I used Python because I am not familar with Bash. I guess there may be 1-liner Bash commands that returns similar result. I am using CrunchBang distro, and it is preinstalled with Conky. I have added an entry to the Conky config file, and the volume information will be displayed on my desktop all the time.

Display volume using Conky

Display volume using Conky

Playing With ThinkVantage Button

After I am done with the volume buttons, I move on to ThinkVantage button. When I press the ThinkVantage button, I want to launch a Terminator terminal. With the help of xev, I discovered that the ThinkVantage button is binded to XF86Launch1. I added the following code to ~/.config/openbox/rc.xml config file.

Posted in Blog at November 26th, 2009. No Comments.

An Algorithm Worth SGD 200!

Hi, my SPR application has just been approved. I will be getting my blue IC in 2 weeks time. I was interested in how the Singapore NRIC number can be verified. After some googling, I found out that it is just a simple mod 11 checksum. It is similar to the Luhn Algorithm (aka Mod 10 Algorithm) used for verifying credit cards. Ngiam has published the algorithm on his website.

According to Ngiam’s slides, one has to apply for an license to this algorithm. The algorithm costs $200, and the sample code cost $400! The algorithm is so simple, any 1st year Computer Science student can easily implement this algorithm. Such simple piece of code is worthed $400, I find it funny.

I followed Ngim’s slide and wrote a Python function. Do NOT use this algorithm to verify your customer’s identity. This is not enough. It can help to detect some typo error, but it cannot verify that the person is holding a valid UIN/FIN. If you really need to verify a UIN/FIN, it is best that you check with ICA.

Posted in Tao Of Programming at April 27th, 2009. No Comments.