Lego my iSight

I got an Apple iSight from Jorge last year. I finally got around to hooking it up when I started working from home a few weeks ago. I was a little frustrated with the little connector that comes with it for mounting, so I did what any self-respecting geek would do; I busted out the Legos.

 

I was going to use my Mindstorm set to build something that could rotate the camera, possibly even write up something to be able to control it from the web, but I didn’t have that much time. I’ll save that project for later.

libnautilus-pr0n 0.1 released

I’ve talked about libnautilus-pr0n a bit over the last few days and I finally have something to show for it — a functional nautilus extension that will display the width/height of an image in the list-view.

It’s a 0.1 release, so there are bugs, but it works and seems to work well from my limited testing.

Go here to download the latest version.

tar zxvf nautilus-pr0n-0.1.tar.gz
cd nautilus-pr0n-0.1
./configure
make
sudo make install

Once installed, fire up Nautilus. First, View -> View as List, then View -> Visible Columns and select ‘Geometry Info’. That’s it.

More libnautilus-pr0n

I made some nice progress on libnautilus-pr0n today. I have it reading the width and height from each image (more or less). I have to see why some images aren’t checked (I suspect my code that detects if a file is an image). I need to make the extension work asyncronously, and have it cache the results so it doesn’t have to re-read the file every time.

libnautilus-pr0n

Kinda cool. It doesn’t sort as perfectly as I’d like. For example, if you were to sort from smallest to largest, an “800×600” image would appear after a “1600×1200” image, because “8” is greater than “1”. I’m not sure if I can take control of that through an extension, so that might require some hacking of Nautilus itself. I could also seperate width and height into their own columns, but I think that would get too messy.

I also started looking at libexif today, so I can add exif columns to nautilus.

libnautilus-pr0n

One of the biggest annoyances I have with Nautilus, and with image viewers/managers in general, is the distinct lack of the ability to sort by image properties such as geometry (width/height), bits per pixel (aka color depth), and aspect ratio.

I started to look at ways I could extend Nautilus to add the features I want and I stumbled across Dave Camp’s blog on Nautilus extensions and providers. As chance would have it, the same night I discovered this Jorge met Dave at Linux World in Boston. Small world.

I grabbed the libnautilus-vcs module from GNOME CVS, which served as a good example of how a Nautilus extension worked, and I now have the functional framework of libnautilus-pr0n (named lovely after the geek term for porn). I want to add a collection of media-related features to Nautilus. The most important feature to me is the ability to sort based on aspect ratio, since I have two wide-screen displays and hunting through unsorted images for ones that will fit a 16:9 display can be a pain. Once I started thinking about it I realized how many other cool things I could add. The ability to sort by color depth (useful for finding black & white photos), perhaps even exif data. Maybe even extend it to audio and video, so you can sort by track length or video dimensions. the possibilities are endless.

Heck, maybe I can even get it included with Nautilus at some point (though I have no idea where to begin with that process).

Here’s a little screenshot of the Visible Columns dialog in Nautilus, with two of my columns included. I still need to write the code to display the data but I have the hooks in place for them.

Mono, DBus, and Hal – Help

Here’s the story. I’m trying to hook into Hal to detect when a device (specifically an iPod) is attached. I can do this in C, Perl, and Python, but I can’t get the C# version to work.

The code should be fairly straightforward. I’m using the definition of HalManager from hal-sharp, which as far as I know is current to the latest Hal spec. DBus 0.23, which is working just fine. My next step is to do some debugging in dbus-sharp and see if I can identify what’s failing and why, but maybe someone has already run into this. I can’t be the only person trying to access the Hal Manager via C#.

The exception:

Unhandled Exception: DBus.DBusException: Disconnected prior to receiving a reply
in <0x0015a> DBus.Message:SendWithReplyAndBlock ()
in <0x0007c> HalManager.Proxy:GetAllDevices ()
in <0x00087> podlet:Main (string[])

The code:

[code]
// Compile with: mcs -target:exe -out:”podlet.exe” -pkg:gtk-sharp -pkg:dbus-sharp ./Main.cs ./AssemblyInfo.cs
using System;
using System.Collections;
using Gtk;
using DBus;

[Interface(“org.freedesktop.Hal.Manager”)]
public class HalManager
{
public delegate void DeviceAddedHandler(string udi);
[Signal]
public event DeviceAddedHandler DeviceAdded;

public delegate void DeviceRemovedHandler(string udi);
[Signal]
public event DeviceRemovedHandler DeviceRemoved;

public delegate void NewCapabilityHandler(string udi, string capability);
[Signal]
public event NewCapabilityHandler NewCapability;

[Method]
public virtual string[] GetAllDevices()
{
return null;
}

[Method]
public virtual bool DeviceExists(string udi)
{
return false;
}

[Method]
public virtual string[] FindDeviceStringMatch(string key, string value)
{
return null;
}

[Method]
public virtual string[] FindDeviceByCapability(string capability)
{
return null;
}
}

class podlet
{
public static void Main(string[] args)
{
Connection connection;
connection = Bus.GetSystemBus();
Service service = Service.Get(connection, “org.freedesktop.Hal”);

HalManager manager = (HalManager)service.GetObject (typeof(HalManager),
“org.freedesktop.Hal.Manager”);

foreach (string device in manager.GetAllDevices()) {
System.Console.WriteLine(device);
}
}
}
[/code]

Advanced Perl DBI

I’ve been doing some bug fixes and performance tuning on some perl modules of mine, mostly related to database access. I stumbled across this presentation from July 2004. If you’re doing any kind of DBI work, check out this presentation. You won’t be sorry.

New Horizons

I feel like I’ve been caught up in a whirlwind these last few days. I met with my two bosses on Friday. They told me they were announcing some major organizational changes on Monday and were giving me a choice: I could either shift into a new role with in a more structured team framework or seek my fortunes elsewhere. I had been expecting something along these lines for a while now. They gave me the weekend to think over my decision.

I really didn’t need a weekend to decide but I used the time to prepare for the biggest leap of faith I’ve had to make. I made some calls, sent some emails and got busy. Dena and I had talked about working for myself for quite a while but making the transition from full-time to self-employment is scary. It’s an entirely new kind of responsibility. It will challenge me in every conceivable way. Despite that I still feel up for the task.

On Monday morning I gave my official notice and started my new life as a freelancer. Oddly enough, I’ve been busier than ever since making the decision — and I’m loving every minute of it.

I realized that life likes to throw curveballs. It’s easy to just wait for the fastball over the plate but sometimes you’ve gotta swing.