Archive for October, 2006

New section for Linux on MacBook

Sunday, October 22nd, 2006

It seems like there is still a lot to be done with getting the MacBook to run nicely on Linux. I’ll try to document all of these on this site, and having separate blog posts doesn’t seem too ideal for a newcomer wanting to get all the info at once. I’ve created the Linux on MacBook page. Most of the information there applies across Linux distros, but once in a while there may be something Ubuntu specific. And once in a once in a while there may be something Kubuntu specific.

MacBook fan control in Linux

Sunday, October 22nd, 2006

Turns out the applesmc kernel module (patch from Mactel) supports viewing/changing the fan speeds on the MacBook. But, when you want to modify the fan speed, you must set it to manual mode and set a fixed fan speed. I’d rather have automatic scaling to heat but specify a minimum fan speed. This was luckily an easy change in the applesmc module (just make the /sys device read/write and allow storing a value to the address). Patch: MacBook Minimum Fan Speed Patch. Afterwards, you can set the minimum speed (in this example, to 3000, double the default minimum speed) by:

sudo sh -c "echo 3000 > /sys/devices/platform/applesmc/fan0_minimum_speed"

Enjoy a cooler laptop!

Opening files from a shell with the default KDE handler

Saturday, October 21st, 2006

There are some things I miss from OS X, one being launching a file from a shell with the default handler. In OS X, I used the open command. In KDE, there is kfmclient which is a tool for communicating with Konqueror. You can type:

kfmclient exec FILENAME

So, I’ve added an alias to my ~/.bashrc:

alias kopen='kfmclient exec'

and can conviently type:

kopen README.rtf

to open README.rtf with the bound handler.

appletouch (Linux kernel driver for Apple trackpads) changes

Monday, October 16th, 2006

It’s been almost two months since I first used OS X on my new MacBook, but I still miss Kubuntu (I’ll have a separate post soon on why). I decided to switch back (well, triple boot–mostly in Kubuntu), but in doing so there have been a few roadblocks. One of these is the trackpad (touchpad) working smoothly–both in terms of moving the mouse and also advanced features of two-finger scrolling, two/three finger taps (for right click and 3rd button click), etc. I changed a few things in the appletouch kernel driver, and the results are pretty good!

The first issue I had was the mouse pointer jumping a few pixels constantly when moving around. The trackpad consists of many sensors (20 on the X axis, 10 on the Y axis for the MacBooks), so when you glide your finger across, each sensor on your finger’s path will go high as the finger approaches/hovers (and go low once your finger leaves the sensor’s ‘zone’). For the trackpad to be used for neat functions (two/three finger functionality), the synaptics X driver should be used, and in order for it to be used, the trackpad must give off absolute coordinates instead of relative (so the actual position of your finger(s) as opposed to the change in your finger(s)’s position). There is thresholding for each of the sensors in order to discard jitter when the finger isn’t triggering a sensor. As soon as a sensor passes the threshold, its value is used (along with the other sensors that are over the threshold) to calculate the absolute coordinates. So, when a finger is approaching a sensor, the sensor’s contribution to the absolute coordinate calculation is 0, but when the finger gets close enough to allow the sensor to pass the threshold, the sensor’s contribution becomes at minimum the threshold value. The default threshold level is 10, so this causes the sensor to go from giving 0 feedback on coordinates, to giving a value of 10 (not exactly) to the function to give coordinates. So instead, I subtract the threshold from each sensor that contributes to the absolute coordinate function. This ends up giving a smooth mouse movement when a sensor suddenly goes from below the threshold, to above.

The second issue was the accuracy of two finger (and three finger) detection. These are used for two-finger scrolling, two-finger clicks, and three-finger clicks, so it’s pretty important in day-to-day use. I found it difficult to trigger the multiple fingers properly (I couldn’t have my two fingers touching each other and I would have to make sure they maintained a good gap when scrolling), so two-finger scrolling was difficult to do. The way it checked for multiple fingers is to count how many sensors that has passed the threshold are preceded by a sensor that is below the threshold. So, the first finger would obviously pass, and then if there is a sensor gap between the first and second finger, the second finger would get triggered. I didn’t like this as I don’t usually leave a gap between my two fingers (OS X didn’t have this constraint). I changed it to check for ‘humps’ in the sensors, so basically check for transitions from nonincreasing to increasing sequential sensor readings on each X/Y axis. This works since the middle sensor(s) (sensors are close enough so when having two fingers down, there will be one sensor between the two) can still be over the threshold and still count as the lower part between humps. After the patch, the two-finger scrolling works as well as OS X (from what I can tell).

The last small issue is being able to change the threshold value. I turned this into a kernel module option (modinfo appletouch).

This patches against Mactel appletouch patch that allows MacBooks to work with that driver. I’ve submitted it to the maintainer of the appletouch kernel driver, so we’ll hopefully see it there!

appletouch-2finger_det-threshold_opt.patch