Archive for the ‘linux’ Category

Firefox and virtual desktops

Thursday, November 16th, 2006

One thing I like about Konqueror is its ability to recognize virtual desktops (load a link in the current desktop’s Konqueror if it exists, otherwise open a new window on the current desktop). Unfortunately, Firefox doesn’t have this ability natively, so I’ve created a wrapper.

Scenario:
kontact (mail app) on Desktop 1. Surfing for a new car on Desktop 3 . New mail comes in, switch to D1, it has a link, I click. Natively, firefox opens the link in my D3 window, ruining my task-oriented desktops (and making me switch to D3 just to see the opened link). What I would have liked is a new window of firefox to be opened in D1, at which point I can decide to move it to another desktop (extremely quickly with my bound keyboard shortcuts), or if it’s a quick task, do it on D1 and be done with it.

This depends on wmctrl (debian/ubuntu: sudo apt-get install wmctrl).

Put this file somewhere (I chose /usr/local/bin/firefox-wrapper.sh) and tell your WM to have it as the default web browser (for KDE: kcmshell defaultapplication).

firefox-wrapper.sh

Put that SPDIF out to use! (as an HDD or network indicator)

Monday, November 13th, 2006

Apple decided we don’t need an LED indicator for disk activity. I decided we do. Using the SPDIF out, we now have one!

I put together a quick little script that’ll poll the proc filesystem and toggle the SPDIF out accordingly.

Check it out: MacBook LED

Both headphone sensing and microphone fixed for Linux on MacBook!

Monday, November 13th, 2006

The current (2006/11/12) state of ALSA for the MacBook (and MBP, ..?) is pretty strange: If you’re using a vanilla kernel, chances are your headphone sensing works (when you plug in headphones, your internal laptop speakers mute and you hear audio from your headphones). If you’re using a mactel-patched kernel (or the generic Ubuntu kernel, maybe other distros that prepatch with mactel), chances are your microphone has the ability to work (you have to toggle between Line-in and Mic on the ALSA mixer for it to work), but your headphone sensing doesn’t (when you plug in headphones, you hear audio from both the internal speakers and the headphones).

After screwing around with the ALSA driver source code, the Windows driver files, and the Microsoft and Intel spec sheets, I’ve found a solution that allows for both the microphone and the headphone sensing to work! Read more in the Linux on MacBook section

Hamachi nicknames to hostnames

Thursday, November 9th, 2006

If you have a set of machines (or friends) and you’re not using Hamachi, you should! Creating a VPN is as simple as joining a room (think IRC, except you’re VPNed with all though in the room). Pretty amazing.

They support many platforms (at least Windows, Linux, and OS X), but one problem I’ve found on the *NIX is there isn’t a way to translate from the nicknames of those in your room to IP addresses without having to refer to the list. I’ve created a bash script to parse the list of Hamachi users in your rooms and place them into your hosts file (/etc/hosts typically).

The general naming convention I use for my Hamachi nicknames are [computer owner’s name]@[computer name], or sometimes even just the [computer name]. An example of the former nickname style would be jason@mooBook (where mooBook is my laptop’s name), and the latter mooMedia (where mooMedia is my media server–like the moo theme?). So, my script will take the [computer name], tack on the room name, and map that newly created hostname to the VPN IP of the machine. Suppose both of these machines are in the room mooNet. I can now ping moomedia.moonet (case insensitive) or moobook.moonet. I’ve tacked on the room name to prevent adversarial behavior (although if you’re in the room com or net or any other TLD, you’re screwed ;).

You only need to run hamachi2hosts.sh once initially and when more users join your rooms. It creates a section in your /etc/hosts for the automagically mapped Hamachi hosts. Please be sure to change the settings near the top of the file. Also, it assumes you’re logged in when you run it.

Here you go: hamachi2hosts.sh

VMware raw partition booting

Wednesday, November 8th, 2006

VMware is amazing due to one outstanding feature: the ability to run a virtual machine from a raw partition. I mention this in Linux on MacBook page, but I highly recommend this for everyone running Linux.

What this lets you do is have a single XP installation, that is able to be booted natively (for games, etc.) and in the virtual machine (from Linux for random things, mostly turns out to be opening Office files that don’t load cleanly in OO).

I’ve updated the Linux on MacBook’s VMware section with detailed instructions on how to achieve this. On the MacBook, I had issues with XP BSODing on boot, so I’ve noted how to fix this.

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