podlet: auto-detection done

I finished integrating the code to auto-detect the iPod via HAL/Gnome2::VFS. I still need to test the VFS cleanup – making sure there are no leaks and whatnot. I also need to tackle automake/autoconf, or whatever it is that supplies ./configure and such. I’m not sure how I’m going to handle dependancies yet. libgnome2-vfs-perl in sid isn’t new enough. The latest version, along with Gnome 2.8, still sits in experimental.

I think for now I’ll worry about the ./configure stuff and make a note in the install file. It’s fairly easy to install the latest libgnome2-vfs-perl and it shouldn’t impact anything else on the system.

podlet: iPod detection

I finished writing the iPod auto-detection code tonight, which means i’m almost ready to move on to syncronization.

This was a fun bit of code to work on. It was my first time working with Gnome-VFS. It took a little while to get the perl binding to work. That ended up being an old version of the library in Debian. Once I installed the latest version, it worked like a charm.


stone@moradin:~/src/internal/podlet/tests$ ./ipod_detect.pl
iPod detected at /dev/sda2

Essentially, it gets a list of all mounted volumes and iterates through them, checking for the existance of the iTunesDB on the volume. When it finds the file, we’ve found the iPod. I have to add a couple signals to detect insertion and removable of volumes and I can call this piece done.

podlet – preferences

I spent my lunch figuring out how to use Glade2 and Perl. Gtk2::GladeXML makes it painfully easy to integrate Glade components.

I have a big chunk of the framework in place and I’ve started attaching widgets. First on the plate is the preferences dialog. The first tab sets the stage about how we’ll recognize and communicate with the iPod. Automatic mounting, or discovery, will use DBUS and HAL to know when the iPod is attached and mounted. Manual will simply probe the mount point and wait for the iPod to be mounted. There are two supported formats – iTunes and GNUPod. GNUPod is great if you only use your iPod with Linux, but if you ever want to sync between Windows, Linux, and a Mac, stick with the iTunes format.

podlet preferences
Gtk2 pretty. Glade2 rocks.

podlet

I’ve talked about working on iPod support for Rhythmbox, and iPod support in general under Linux. I did do some work with Rhythmbox, but in the end I faltered and gave up on it. The future of Rhythmbox isn’t clear to me, and from the start I had qualms about writing application-centric support for something like the iPod. After much internal debate, I’ve decided to take a fork in the road.

I’ve been using Perl quite a bit lately. Then I discovered GNUpod. The wheels began to turn. I started to play with gtk2-perl. More cogs began to spin.

Thus was born podlet, a perl application that uses Gtk2::TrayIcon (which follows the freedesktop.org System Tray specification). In essence, it will be a complete syncronization tool, not just for music but also contacts, calendar, and tasks (not limited to, but including this bounty).

podlet
Proposed look of podlet, sitting in the Notification Area. The icon changes based on the current status – idle, syncronizing, or disconnected.

One- and two-way syncronization of music. I use my iPod with my laptop, but I don’t want to keep a full backup of it on there. One-way syncronization would let me syncronize music to the iPod without filling my hard drive. Two-way syncronization, as you would expect, would make sure that your library on your iPod is a mirror of that on your computer.

Calendar, contact, and task syncronization should work with any application you choose to use. There will be a plugin system to support various sources for this PIM data, so you can sync your iPod with Evolution, vcards, Thunderbird, Sunbird, etc.

In the end, I think podlet will make a pretty decent little syncronization tool. I’ve thrown my work into CVS and started to hack out the core of what needs to be done. I’ve also started to play with Glade. There will be a preferences dialog to manage podlet’s settings, and possibly a druid to be run on first run to walk the user through setting up syncronization.

Automating Mozilla to create Thumbzilla

I love my job. One of my ideas got the green light a month or so back and I’ve been building it (while juggling other projects) ever since.

It wasn’t a unique idea, but it was one that would compliment our other image-related ad services: Web Thumbnails. Essentially, create a small thumbnail of a rendered website and use that as a visual representation of a link before someone clicks on it.

Something like this:

Ars Technica Ars Technica: The PC enthusiast’s resource
Ars Technica. Power users and the tools they love, without computing religion.
Oh yeah Ars Technica review: The Sims 2. Posted September

arstechnica.com/ – 63k – CachedSimilar pages

(Web result borrowed from Google)

Creating the actual thumbnail is not that impressive of a feat. There are dozens of ways of doing that. The real trick, in my book, is creating an automated method of doing so. No technology is worthwhile, in my opinion, of it doesn’t make some task easier.

With the help of Mozilla and Gtk2::MozEmbed, I build Thumbzilla (okay, the name is cliche and taken, but for an internal project, it works). I almost immediately ran into a pickle of a problem: Javascript. Some of the sites I was attempting to thumbnail did not want to play very well with an automated process. When I logged in to check Thumbzilla’s progress I was greeted with a slew popups, alerts, and confirmation dialogs. Nasty stuff.

Obviously, anything requiring manual intervention is a wrench in the cogworks of my project so I did a little digging. I ultimately found this:

Suppose you’re annoyed by pop-up advertisements and want to prevent all
web pages from opening new browser windows. You can do this by adding the
following line to your Mozilla user preferences file (user.js):

user_pref("capability.policy.default.Window.open", "noAccess");

Throw in a little:

user_pref("capability.policy.default.Window.prompt", "noAccess");
user_pref("capability.policy.default.Window.alert", "noAccess");
user_pref("capability.policy.default.Window.confirm", "noAccess");

and my system is now chugging along quite nicely, with some of the annoyances of Javascript disabled. It will be several weeks minimum before Thumbzilla is publicly unveiled, during which time it will get tested, poked and prodded by various people. Still, I have to say I’m quite proud of how it turned out. I think this kind of visualization could be a useful part of searching the web. Let’s just hope I’m not the only one who thinks so.

Riding the D-BUS

D-BUS is a message bus system, a simple way for applications to talk to one another.

I was looking for a better way of doing inter-process communication (IPC) and I stopped to take a look at D-BUS. After playing with it for a few days and seeing it in action via beagle, I decided it was worth using.

I’ve started work on xchat-dbus, and X-Chat plugin to expose plugin functionality via D-BUS. The advantage to this is that other applications could interface with X-Chat without having to use a plugin and then find a way to communicate with that.

This started out as an idea to create a simple applet that would provide alerts via the notification area. I found one such applet, but it was overly complicated and didn’t work well. I started to write an X-Chat plugin to do it, but then I realized how much easier (and ultimately more useful) a D-BUS plugin would be. Plus, this will let me dig deeper into D-BUS and hopefully I’ll get a better grasp on it’s internals.

Mono, HttpWebRequest and https/ssl

I just spent the better part of a week tracking down bugs in Mono and a custom application of mine (which I’m porting to Mono). I was having a rough time with some code working against a secure server. After reading this, this, and this, it finally works.

Bottom line: If you’re working with HttpWebRequest and trying to connect via SSL, you need to make sure that you tell System.Net to trust all certificates, especially if you’re developing a non-interactive daemon. There’s nothing more frustrating then spending hour upon hour tracking down why your code won’t work like it did under .NET, only to find out a few lines of code fixes it straightaway.

Rhythmbox w/iPod progress

I took a week or so off of iPod work to take care of other pressing issues. Now that things are finally settling down, I sat down to finish what I started, namely, support for the iPod name in Rhythmbox.

screenshot

Nothing fancy. It reads the DeviceName off of the iPod and sets it as the name of the iPod in the sources list. This officially becomes my first patch to Rhythmbox. Wee, I’m so excited. I have more iPod-related work I want to do, including:

    Make iPod name editable
    Drag and drop files to the iPod
    Syncronize the iPod
    Playlist support
    Whatever else sounds like a good idea

It’s a start. I wanted to start with a small change, so that I could get comfortable with the internals of Rhythmbox. I’m feeling pretty good about it now. It’s going to be a happy day when I plug in my iPod and sync with my music library with Rhythmbox.

libipod, or what motivates me

I started playing with ipod support in Rhythmbox a while back. I mocked up a little bit of the GUI, but then I made the mistake of looking at the libraries that interfaced with the ipod. There have been some efforts at getting ipod support under Linux, most notably gtkpod. There are a handful of various efforts at making GUI to interface with the ipod, but I found very little effort going into making a stand-alone library to access it.

Following the Open Source tradition, I decided to write my own library to interface with the ipod. I did this with sound reasoning. First, the existing projects that I did find all seemed to be trying to do their own thing (nothing wrong with that), each implementing their own version to accomplish a similar task. While there’s nothing necessarily wrong with that, it feels more `right` to me to create a more generic, independant shared library to interface with the ipod (and specifically, iTunesDB, which is the heart and soul of the ipod). With a shared library, I can integrate ipod support into any number of applications (xmms, Rhythmbox, gnome-vfs, etc) without having to worry about rewriting the same code over and over again, which gtkpod and others seem to be doing.

I talked to a few developers involved in other ipod-related efforts and met some resistance to my idea. Again, the efforts I witnessed seemed to focus on building application-specific support. On that vein, I took a look at my own motivations compared with that of other developers that I know and I came across some interesting bits of information.

Reading through a presentation [3.4M] given by Nat Friedman at GUADEC recently, I found and have shamelessly ripped out the pyramid of usability.

pyramid of usability

I place myself somewhere between core hacker and geek. I’m more than happy to hack away at code but I don’t find as much satisfaction in something that only I can use. I guess I prefer to look at things from an end-user perspective. They don’t care how complicated it is to write code or what effort went into it. They just want it to work. At least I’m not alone in this.

I know where I stand, but what about the community at large? Jorge pointed me to this study on the motivation and effort in Open Source software projects, conducted with a pool of 684 developers across 287 sourceforge.net-hosted projects. They concluded with some interesting results.

44.9% write code because it’s intellectually stimulating.
41.8% write code to improve their skills
33.8% write code because it is needed for work-related projects
29.7% write code for non-work-related projects
11.3% write code to spite closed-source projects
11.0% write code to enhance their reputation in the Open Source community

I can relate to these motivations but I can’t help feeling that something is missing. I don’t expect the code I write to save the world but I would like it to contribute to making Linux more usable to the end user. If I sync my ipod with Linux, it should work the same no matter what frontend I use. I should even be able to sync between whatever application I use in Linux and iTunes on Windows or OSX. It shouldn’t matter what application I use on which platform. It should just work.

So that’s my goal with libipod in a nutshell, as lofty as it may be. It should provide a seamless interface between any application using it and iTunesDB and allow the ipod to work with iTunes or any other compatible software.

Making firefox your default browser (and open URLs in a new tab) in Gnome

Okay, that was a wordy title but what can I say, it fits the bill. I wanted to use Firefox as my default browser, yet open new links in a new tab. This is how I managed to make it work.

I created firefox-tab.sh in my ~/bin. In it, I put in one line:

firefox -remote “openurl($@, new-tab)” || firefox “$@”

What this does is tell firefox to open the url in a new tab, or if firefox isn’t running, launch firefox and open the url.

Next, I told GNOME to use `~/bin/firefox-tab.sh %s` as my default browser (vary as necessary for your window manager). Now, whenever I click on a link, it opens in firefox. It’s quick, simple, and does what it needs to do. I’d prefer to make it open the tab in the background, but I haven’t found anything in the remote documentation that indicates this is possible.