Archive for the ‘Tech’ Category

Ubuntu on an HP Compaq dx2300 Microtower

Thursday, March 19th, 2009

My new desktop at varsity is, as described in the title, an HP Compaq dx2300 Microtower. First thing I did when I got access to it was, of course, to install Linux – Ubuntu 8.10 in this case. It’s a pretty nice machine (although not particularly high-spec) and pretty much everything worked straight away from install. The graphics card is Intel, so I’m not going to be doing any serious gameplaying (this is a work computer, anyway) but it runs Compiz pretty well. Being a desktop, suspend and hibernate aren’t terribly important, but as it happens they work fine.

The only problem – and this is the main point of this post – was with the soundcard (an Intel HDA). The box has three audio outputs: headphone plugs front and back, and a tinny built-in speaker. Under Ubuntu all three outputs were switched on all the time, and it wasn’t possible to adjust them separately. The purpose of headphones in a shared lab environment is entirely defeated if the built-in speaker is always on! I tried fiddling with all of the multitude of ALSA settings, but nothing worked. It couldn’t have been a hardware problem, because it did the right thing under Windows.

So, the problem was narrowed down to the audio driver, snd-hda-intel to be specific. Some googling established that changing the model parameter to the module might have some effect on the output selection behaviour. Further searching established that the possible values are listed in Documentation/sound/alsa/HD-Audio-Models.txt in the kernel source.

To find out what the possible values are, you have to know which codec your card uses. This you can do by running

cat /proc/asound/card0/codec#0 | grep Codec

For the dx2300 the result was Realtek ALC888. Indeed, under the list of models for the ALC888, there is one called “3stack-hp” for “HP machines with 3stack”. Guessing that this was the correct one, I added to /etc/modprobe.d/alsa-base the line

options snd-hda-intel model=3stack-hp

and rebooted. Hey presto, suddenly the internal speaker switches off when headphones are plugged in.

tl;dr summary: If you have a dx2300 and you’re having problems with the audio under Linux, then add the line options snd-hda-intel model=3stack-hp to the file /etc/modprobe.d/alsa-base (at least in Ubuntu; your distro might put module options in a different file).

Whois-related irritation

Tuesday, January 13th, 2009

Responsibility for the African IP ranges was transferred to AfriNIC what, four years ago, right? So why is it that some services that use the whois data still ignore the AfricNIC whois data? The result of this is that they believe that all African IP addresses are in Mauritius. If you’re on a South African IP, you can see this with, for example, the WhatsMyIP.org service by going to http://www.whatsmyip.org/more/ and looking at the “Whois Lookup” information.

Also, Netcraft should really know better. Check out the Netcraft information for the UCT website. It’s not like this information hasn’t been around for a while; all the open-source whois tools started using the AfriNIC server long ago. (I myself submitted the bug and patch for FreeBSD.) So really, they need to get with the program.

Update: I may have maligned Netcraft unfairly. Although they get the UCT information wrong, most SA sites do show up correctly. SAIX, for example. I’ve sent them a bug report.

HSDPA modem and custom routing

Tuesday, January 13th, 2009

So, for my Christmas present to myself I got a Huawei E220 HSDPA modem – it’s one of the Vodafone-branded ones, but I reflashed it with the generic firmware. Anyway, it’s an awesome thing to have for a geek like me – I can be connected to the Internet at broadband speeds almost anywhere in the city. It’s particularly useful when i’m on campus, so I can avoid the dog-slow UCT internet connection.

Problem is, I’d like to stay connected to the UCT network as well so that I don’t use up my precious* data bundle for UCT services, and this requires a bit of custom routing magic. So I have a script:

#!/bin/sh
GATEWAY=137.158.32.97
route add -net 137.158.0.0/16 gw $GATEWAY
route add -net 192.48.253.0/24 gw $GATEWAY
route del default
route add default ppp0

137.158.0.0/16 and 192.48.253.0/24 are the UCT netblocks, and 137.158.32.97 is the router on the subnet that I’m mostly using at the moment. ppp0 is, of course, the name of the interface associated with the HSDPA connection.

The problems with this script currently are that I have to edit it to change the gateway for each subnet that I’m on, that I have to run it manually each time I connect, and that it doesn’t restore the original routing when I disconnect. The first and third problems should be reasonably easy to solve, but the second will probably require that I dig into the mysterious world of NetworkManager. (Cue dramatic music.)

*It’s ourssss, my preciousss… they wants to take it from us, the nasssty Vodacom…

Blog resurrection

Tuesday, December 9th, 2008

OK, so I’ve rather neglected this blog for the last few months. In my defense, I can offer that I was finishing my Honours degree, including the notoriously timeconsuming major project. But that is now over (thank heavens) and I am free at last. (Shout it from the rooftops!) So hopefully I will have a little more time to spend on leisure activities like blogging.

I’ve also found the time to finally upgrade the Wordpress install that runs this blog. (It was still at 2.3.3, and the current is 2.6.5!) As you will notice, I’ve also returned to the default Wordpress theme. I know it’s boring, but it actually looks fine and it works well enough.

Impressed with Telkom

Tuesday, July 8th, 2008

We South Africans complain frequently about Telkom and the level of service it provides; and mostly the complaints are justified. But it is only fair that, when Telkom provides good service, we should also take note of it.

My phone and DSL line started having issues about a week ago, and it was becoming progressively worse: there was heavy crackle on the voice circuit, and the DSL line was showing about 20% packet loss. On Thursday evening I reported the problem through the fault reporting website.

Early this morning they phoned me and informed me that the technician would be able to visit later today, and he did indeed arrive at about 11. Because of the nature of the problem – an issue with the lines between my building and the distribution box – he had to travel back and forth a few times between my flat and the box on Main Road, so the process did take a while. Nonetheless, throughout the experience he was friendly, efficient, and competent.

I should mention in particular that at no point did I have to deal with the notorious callcenters and the interminable on-hold music. I didn’t have to spend any of my cell-phone minutes waiting for someone to take note of my problem. All I had to do was fill out the form on the website, and wait for them to get back to me – which only took two working days.

This is a marked contrast from my experience two years ago with my parents’ broken phone line, where it took five days and many hours on the phone to get the DSL and line repairs departments to agree on who was responsible for fixing the problem.

Load shedding bot FAQs

Thursday, April 17th, 2008

Since posting about my Jabber load shedding warnings bot I’ve had a couple of questions asked about it. So here are the answers:

Where does the data come from?
The City of Cape Town has posted on the web the load shedding timetable as an Excel spreadsheet. I do a bit of manual manipulation on the spreadsheet before dumping it to a CSV file. Then I have a script which parses the CSV file and generates a SQLite database.

What’s the bot coded in?
Python. (Of course.) It uses the xmpppy module to do the Jabber communication, and SQLObject for the database.

How does it work?
The bot is actually made up of two separate components. There is a control daemon that is always available on Jabber, which accepts subscriptions and responds to your commands. Then there is a queuerunner fired by cron at the appropriate times, which sends the warning messages; it uses a negative Jabber priority, so your messages to the control daemon will never go to the queuerunner by accident.

How many users do you have?
As of 18 April, there are 20 users. The average user subscribes to warnings for two different locations.

Get load shedding warnings via Jabber

Saturday, April 12th, 2008

Tired of having the power go out without warning? Now you can get warnings about predictable load-shedding sent to the Jabber account of your choice – including Google Talk accounts. Unfortunately, at the moment the warnings are for the City of Cape Town supply area only.

To set it up, ask your Jabber client to subscribe to loadshed@frith.co.za – in Pidgin that’s the “Add Buddy” command, in GMail it’s “Invite to chat”. The loadshed bot will accept your subscription, and reciprocate with a subscription request to you. When you accept it, the bot will send you instructions about how to proceed.

You can search the list of suburbs by sending the message “search [text]“, which will give you a list of suburbs in the City Council’s list with a name matching “[text]“. Then you can subscribe to warnings for a suburb with “subscribe [number]“, where [number] is the number that was listed next to the suburb in the search results. There’s also a “list” command which shows what susburbs you’re subscribed to; and “unsubscribe [number]” which works in the same way as “subscribe”.

The bot will send you warnings 15, 10, 5, and 2 minutes before the load shedding period is scheduled to start. A planned future development is to make the warning times configurable.

XRandR – finally, simple monitor configuration for Linux

Thursday, December 6th, 2007

The most recent Linux distribution releases – Ubuntu 7.10, Fedora 8 and so on – are now shipping with version 1.2 of the XRandR extension for the X server. This allows the user to dynamically change resolutions, refresh rates, and – this is the really impressive thing – switch monitors on and off on the fly. All of this, without ever having to edit xorg.conf, or restart the X server, or reboot. This was one of the major things that the Linux desktop lacked compared to other major operating systems.

Until very recently, using my external monitor with my laptop required several irritating customisations – you can see the details in my earlier post:

  1. To have it switch on, and run in Xinerama mode along with my laptop panel, required fiddling with MetaModes and other fiddly settings of the radeon driver.
  2. To drive it at its native resoution (1440×900) i had to add a custom modeline to xorg.conf (except on Fedora, for some reason).
  3. If the X server originally started without the external monitor attached, then it would have to be restarted to detect the monitor once it was attached. And restarting X means having to log out and lose all my application state.

XRandR 1.2 has removed all three of these irritations. It requires (almost) no preconfiguration, autodetects all resolutions correctly, and detects monitors when they are plugged in without a restart.

Let’s take a brief look at some of what XRandR can do: this is basically what I do with it daily. Note that at the moment graphical tools to control XRandR are still under development and none are really at a releaseable state (in my opinion); but now that the infrastructure exists in the X server and the drivers, tools to control it will come soon. What I use here is the command-line tool, sensibly named xrandr. (more…)

Blog revamp

Monday, November 26th, 2007

I’ve upgraded the blog to the latest version of wordpress (2.3.1, I think) and changed the theme. I’ve also added the WP-OpenID plugin so you can now provide an OpenID identity while commenting, or associate an OpenID identity with your account and use it to log on. Also, the theme has changed.

In the process I (through my own stupidity) lost the images that should appear in some of the posts. I think I have a backup at home, so they may or may not reappear later.

SCO is bankrupt

Monday, September 17th, 2007

Well, not quite. Remember what I (along with half of the world – I’m not claiming any particular brilliance on my part) predicted a month ago? That SCO would file for Chapter 11 bankruptcy protection? Well, it’s happened. Hopefully we will soon be seeing the last gasps of SCO.

In other news: Microsoft loses anti-trust appeal. All in all, a bad day for IP trolls and monopolists.