Hmm… Aha…

stuff might interest somebody

Posts Tagged ‘macosx’

Add ‘Where from:’ to Firefox downloads (Mac OS X)

Posted by f3lix on January 9, 2009

If you used Safari before you switched to Firefox, you might miss Safari’s feature that annotates each download with the URL it was downloaded from.  So if you find file in Download folder and wonder where it came from, you use Finder (“File > Get Info” or CMD+I) to show it’s source URL. Or if you like the shell, you can use the mdls command-line tool to get the info:

#> /usr/bin/mdls -name kMDItemWhereFroms a_downloaded_file.pdf
kMDItemWhereFroms = ""

Manually setting the “Where From:” URL

Today I asked myself if there was also a way to write this data. I did a little research on the web and found out the “Where From”-URL is actually saved in as an extended attribute. Extended attributes can be manipulated with the xattr command. So you can specify the URL for a file by running

/usr/bin/xattr -w '' <filename>

Make Firefox to set kMDItemWhereFroms

Now, what we really want is to have Firefox set the kMDItemWhereFroms property for us automatically. As I’m not familiar with programming Firefox extensions. I decided to modify an existing one: Download Statusbar I only had to write the following function, add it to the Downbar.prototype in downbar.js and call it from the db_finishDownload function.

    db_SetMetadata: function(aDownload) {
        var cmd = '/usr/bin/xattr'
        var execFile = Components.classes[";1"].createInstance(Components.interfaces.nsILocalFile);
        var process = Components.classes[";1"].createInstance(Components.interfaces.nsIProcess);
        // Arguments must be separated into an array
        var args = ['-w', '', "'"+aDownload.source.spec+"'", aDownload.targetFile.path ];
        if (execFile.exists()) {
  , args, args.length);

You can also download a patch at

Edit: for download bar the patch is a tiny bit different. see


Posted in Mac OS X | Tagged: , , , , | 7 Comments »