Monday, October 22, 2007

Ubuntu and Avahi

More from the 'why Ubuntu sucks' front.

Wireless networking has been extremely questionable on this laptop. Sure, the driver works, and if the NIC ever gets around to being configured via DHCP, everything is fine. For awhile.

I first got the wifi up and running with knetworkmanager running under fluxbox. This seemed to work, even though you have to type in the network password every time (kwallet gets started, supposedly to save the password for you, but aside from prompting you for the wallet password I've yet to see this do anything useful).

The problem arose when I moved to e17. No system tray, so no knetworkmanager. Aside from demonstrating a design flaw in the NetworkManager package (only GNOME and KDE systray applets, no Gtk, Qt, or CLI applications), this didn't seem to be too much a problem; just write a shell script that does the ol' "ifdown; iwconfig; ifup" right?

Wrong. The interface can be configured this way, sure, but that has no effect on actually bringing the interface up. The DHCP times out with no response. I started a second Xsession running fluxbox and ran knetworkmanager, without connecting to the network, and went back to e17. At some point in the next half hour (I stopped checking after the first10 minutes), the interface got configured, and the wifi worked fine. I closed knetworkmanager and fluxbox and got some work done, went to sleep, woke up and found the wireless interface has unconfigured itself.

Got bit angry at that; it's a special case of a cardinal UNIX rule: choice of window manager and running applications should not effect the network connectivity of the machine. We're getting into Windows and OS X territory here; Ubuntu is no longer UNIX. Ubuntu is starting to stink of crap.

To wrap things up, I tracked the problem down to Avahi (specifically, avahi-autoipd) and removed it, as I don't have discoverable devices on my wireless network anyways (what fool does?):
bash > sudo apt-get remove avahi-autoipd avahi-daemon
The following packages will be REMOVED:
avahi-autoipd avahi-daemon kdenetwork kdnssd libnss-mdns
I restarted debus, hald, networking (after modifying /etc/defaults/avahi-daemon), and all that ... no dice. Against my better judgement, I rebooted.

After rebooting, my ifdown/iwconfig/ifup script worked just fine. Welcome to Windows, guys!

I'm really starting to wonder why I should stick with Ubuntu over plain Debian. I'm not using their version of KDE or GNOME, since I prefer e17. I had to build a custom kernel for my laptop hardware, and Ubuntu does not allow this (you cannot reconfigure their kernel source package and expect it to compile, something they stubbornly refuse to admit is a 'bug'). I guess the ability to install AVI-viewing software without any pain is useful, though that's really a fault of Debian than a feature of Ubuntu.

For the curious, here is the shell function I use for starting a second X session:

alt_wm () {
if [ -z "$1" ]
echo Usage: alt_wm path [screen]
return 1

[ -z "$SCREEN_NUM" ] && SCREEN_NUM="1"

xinit $1 -- :${SCREEN_NUM}

Wednesday, October 17, 2007

E17 profiles

I finally got around to playing with E17 profiles, which are located under the 'Advanced' section of the Configuration Panel. I kinda figured that, the E guys being who they are, I could use these to toggle between CPU-eating animated backgrounds/icons and normal static backgrounds when the laptop is running on battery or A/C power. I was right!

I put the following script in /usr/local/bin/ :
#!/usr/bin/env bash

# Switch e17 profile based on arg1

# 1. Check if E17 is running
if [ `ps ax | grep enlightenment | grep -v 'grep' | wc -l` -eq 0 ]
# no enlightenment running
exit 0

# 2. Make sure E_IPC_SOCKET is set
if [ -z "$E_IPC_SOCKET" ]
# we are called from outside of e17
E_IPC_SOCKET=`ls -a /tmp/enlightenment-*/disp-*`
if [ -z "$E_IPC_SOCKET" ]
# something wrong with enlightenment!
echo "Cannot set E_IPC_SOCKET!" >> /dev/stderr
exit 0

# 3. Get username to switch to
if [ $# -gt 0 ]
# switch to default

# 4. Switch enlightenment user!
E_IPC_SOCKET="$E_IPC_SOCKET" enlightenment_remote -default-profile-set $profile
This has the usage ` profile_name`, with 'default' being used when no profile name is provided.

I then modified /etc/acpi/ as follows:

function laptop_mode_enable {
# Local Changes ---------------------------
/usr/local/bin/ battery
telinit 4
# -----------------------------------------


function laptop_mode_disable {

# Local Changes ---------------------------
telinit 2
/usr/local/bin/ ac
# -----------------------------------------
There are three changes from the Ubuntu default:
  1. LAPTOP_MODE is enabled (see /etc/laptop_mode/laptop_mode.conf )
  2. The battery runlevel is 4, while the A/C runlevel is 2 (the default)
  3. The e17_profile_switch is called to set the profile to either 'battery' or 'ac'
Obviously the remaining step is to create those two profiles in E17, and set them up accordingly.

The runlevel trick is one I've been using for awhile: I modify one of the existing runlevels to kill off unnecessary daemons, and optionally to run shell scripts (placed in init.d of course) to do things like change the hard drive spin-down time or the CPU frequency governor. Note that laptop-mode-tools provides this latter capability, so my current battery runlevel just kills off services that aren't that important:
bash# ls -1 /etc/rc4.d
Some of these may seem strange choices, but I tend to not use the net when on battery (usually I'm holed up at a coffee shop coding), and likewise I avoid resource-intensive applications (Open Office, KDE, multimedia, etc). If I really want to stretch the battery life I'll kill X, but Acroread and Firefox are a bit useful for consulting documentation.

Monday, October 8, 2007

First Impressions

It's been a month or so, and I've been using the r500 on a daily basis for work (coding, browsing, email, documentation, etc). I've had a bit of time to get used to it; here are my thoughts.

Case/Form Factor
The r500 is just about the perfect size. After the Sharp Actius, I wanted my laptops to be the size of one of those Mead composition books. The size of the display and keyboard on the r500, however, are probably ideal; if this were as thin as the Actius MM20, it would be perfect.

The weight cannot be beat. A friend held it and said "it feels like paper!", another said "haha, very funny, now where is the actual laptop." Even after the Actius, and in direct comparison to the Vaio Tz and G2, this has to be seen (and hefted) to be believed. The slightly larger size is what does it; there is almost no mass to this.

Contrary to the impression of the pre-release reviews, I find the r500 to be quite durable. There is a small bit of flex in the seam at the front of the keyboard, and the case picks up smudges somewhat easily, but I've chucked this in my backpack and hauled it all around town without a problem.

The keyboard is great: decent size, nice and responsive. The touchpad is interesting: it feels the same as the surrounding case, which gives it a bit more traction for your finger. I'd still prefer one of the nipple/eraser/trackpoint mouse jobs, though. Be nice to have those as an option again.

There is a ton of light bleeding from the edge of this, which doesn't bother me, but the viewing angle is VERY bad. Only noticeable when viewing dark colors; the brights are all fine at most normal angles. Using a dark WM theme and sitting on a train seat or a couch, you certainly notice.

Suspend-to-RAM works fine out of the box; suspend-to-disk worked with a fresh kernel compile, though I had to resume via single user mode for some reason. Suspend-to-disk is probably ideal for this machine, given the SD drive. Suspend-to-ram takes 10 seconds or more, and is as stable as every other Linux laptop that suspends to RAM (i.e. one time out of 10 it will resume incorrectly). One downside of suspend-to-ram is that it is a battery hog; I've had the
machine lose 30% of its battery when suspended for 6 hours or so.

The 3-cell battery that comes with this lasts about 3 hours; I haven't tried the 6-cell. I've made some changes to get a bit more life out of this, and may have it at 4 hours for normal usage soon (more for no net/browsing/X). Charging time is horrible, almost as long as it takes to drain the battery. Also been noticing some funny stuff when trying to run down the battery recently: when idle, the laptop will stay at 3-4% (via the 'acpi' command) with 4 or so minutes left for 10 or more minutes.

SD Drive awesome. Fast, fast, fast. For those on the fence, it is well worth the price. Suspend/resume suddenly becomes less important, since booting takes only a few seconds. And suspend-to-disk is suddenly viable.

The wifi works great, no fuss. Ditto for audio, display, lan, usb, etc. The SD reader is one of those "known problems" that should be fixed in the kernel soon (my guess is 2.6.24). The fingerprint reader may actually work, as it is recognized by SANE. I've had no luck with bluetooth, though I've only spent a few minutes on it. And the toshiba ACPI kernel support as used by toshset seems worse with the latest patches; none of the LCD controls work any more, and there doesn't seem to be a way to turn the backlight off (which toshset should perform)
-- so no fun transreflective display.

Wednesday, October 3, 2007

ProActive Record

Been reading Pro ActiveRecord by Kevin Marshall, et. al., in preparation for moving our PHP webapp to Ruby. It's a small book, and arguably one could just read the ActiveRecord source, but let's face it: no-one's going to print that stuff out and read it on the subway.

For anyone doing anything serious with ActiveRecord, such as welding it to an existing, properly-defined (as opposed to rails-auto-created) database, this book is highly recommended. Clear, concise, and thorough coverage with good examples.

I haven't read the chapter on legacy databases yet, but I know from the first 5 chapters that I can make ActiveRecord do what I need it to without too much trouble, which helps a lot in planning this project.