Tuesday, February 2, 2010

QuickLook and Ogg

UPDATE: Wow, I can't believe I made this mistake! There should've been a line *before* the first <array>. It's fixed now (it only took me a while :/)
I just stumbled into yet another roadblock to the free software alternative to MP3, Ogg: QuickLook fails to preview ogg vorbis files.  I knew QuickTime would play Ogg Vorbis after installing the XiphQT component so I installed that.  Still, no QuickLook previews for Ogg Vorbis.  I now had a mission.

I started with a google search for quicklook and ogg, nobody seems to have written a QL plugin for ogg yet.  I ran across a few blog posts about adding text types to TextEdit so that they could be previewed by QL and thought to myself: can this be extended to QuickTime?  One short patch to QuickTime's Info.plist later and I found out that it could!!

Append the following above the last 2 lines of your QuickTime's Info.plist (the last 2 lines are </dict> followed by </plist>), save it, then move QuickTime out of your Applications folder and into a folder *not* in the Applications folder hierarchy, then move it back. Problem solved!
<key>UTExportedTypeDeclarations</key>
<array>
 <dict>
  <key>UTTypeConformsTo</key>
  <array>
   <string>com.apple.quicktime-movie</string>
  </array>
  <key>UTTypeDescription</key>
  <string>OGG Audio/Video file</string>
  <key>UTTypeIdentifier</key>
  <string>org.xiph.ogg</string>
  <key>UTTypeTagSpecification</key>
  <dict>
   <key>com.apple.ostype</key>
   <string></string>
   <key>public.filename-extension</key>
   <array>
    <string>ogg</string>
   </array>
  </dict>
 </dict>
</array>

Saturday, January 9, 2010

Application-Specific Wacom Buttons

EDIT: Updated!
EDIT(Jan 14): Updated again.  It seems that in the previous version, the app would stop working after the computer was put to sleep.  Hopefully this update fixes that problem (I haven't tested it but the changes won't stop the rest from working).
How many people have been plagued by the scrolling problem present in Firefox 3.5+ when using the panning feature of Wacom tablets?  I know I have been but now there's a partial solution: a little app I developed called AppSpecificWacom.

This app allows you to set what buttons on the pen do what for a specific application.  I wrote this because support for this doesn't exist for the Graphire tablets and I required app-specific settings.

Currently, it's limited to the first pen device (no mouse, puck, etc) registered in the first detected tablet.  For me, that's the pen. UPDATED: use the transducer and tablet keys to modify which tablet and device to remap.  As a consequence, the list of applications are now in the Applications array.  As another consequence, you must remove your current preference file in your Library/Preferences folder.

Drop this app in your startup apps and edit "/Users//Library/Preferences/com.r0ssar00.AppSpecificWacom.plist" for your application-specific requirements.

In short, to target an application, you may use either the name or bundle identifier of the application.  Example: for Firefox, to target using the name, you would use

<key>name</key>
<string>Firefox</string>


to target using bundle identifier

<key>bundle_id</key>
<string>org.mozilla.firefox</string>


I recommend you target using the bundle identifier.

As for the button remaps, do something similar to

<key>tip</key>
<string>click</string>
<key>barrel</key>
<string>right click</string>


Currently, you may use: tip, barrel, barrel2, eraser
barrel is the button closest to the tip and barrel2 closest to the eraser.

For the remap, you may use: back, forward, click, double click, click lock, right click, middle click, pan, 4th click, 5th click, pressure hold, mode toggle, auto erase, erase, ink toggle, show desktop, show help, pie menu, supa fine

The default mapping for the eraser is auto erase.
The default mapping for the tip is click.

On startup, it stores the current mappings so you won't lose them but if you currently have any of the buttons on the pen mapped to either a run application, keystroke, or the menu, this may be lost(I haven't tested it).  I may fix this in the future but right now, I'm not using it so I'm not writing code to support it.

EDIT: renamed the application!  Make sure to delete any old versions and remove the original startup item before you use the new version.  Also, the old preferences won't be copied over so before you run the new version, rename your preferences file to com.r0ssar00.AppSpecificTablet.plist
Grab the binary here.

EDIT: oops, forgot to mention how I managed to fix the Firefox scrolling issue using this.  I setup barrel2 to middle click in Firefox and then installed the Grab and Drag extension for Firefox.  I then setup Grab and Drag to initiate a drag when the middle mouse button is pressed.  Added bonus: middle-clicking a link will still work :D

GeekTool Updates

[And now back to regularly scheduled programming]
Fact GeekTool 3 is applescriptable.  You can tell any given shell or image "geeklet" to refresh using applescript.  This reduces system load incurred by running GeekTool considerably

Suppose you have an geeklet displaying your unread email subjects.  You'd also like to have a count of your unread email somewhere too.  Previously, you'd have to have both refresh every x number of seconds.  Now, the subjects (or count) geeklet refreshes every x seconds and in the script that is executed by GeekTool there's a line that tells the other geeklet to refresh.  Just make sure the geeklet being told to refresh has a refresh time of 0 (previously, this would cause GeekTool to attempt to refresh at every instant but now it just disables automatic refresh).
I'm using this exact situation for both my email and remember the milk geeklets.

Fact iTunes posts track status changes to the distributed notification system.  These changes include when the current track changes and when the playing status changes from/to playing/paused/stopped.

Fact crankd will listen for notifications and act upon them.  crankd is a piece of software that was written to replace a piece of technology present in 10.4 but eliminated in 10.5.
Caveat crankd doesn't support the notifications iTunes posts out-of-the-box but I've written patches to support the proper notifications and have submitted them to the project (through the issues section).
Caveat this requires root privileges due to this issue.  If you can, give yourself sudo with NOPASSWD for launchctl.  If you can't, you won't be able to pull this off.  I'm not describing or supporting this, there's documentation elsewhere.
Download crankd, then download the version of crankd here.
Install Run the crankd install package.  Copy the version you downloaded from this (same as above) issue page into /usr/local/sbin/ replacing the existing crankd.  Read comment 1 at the issue page.  Do what it says.  Read this issue and do what it says.

Now to write the script:
crankd drops title, artist, album, and several other attributes into the environment of a script that it executes.  They are appropriately named NAME, ARTIST, ALBUM, etc.  Use these to write a script that gets this information to GeekTool somehow.  If you want the full list, put a call to env into the script, piping it to a file, then open that file once the script has been executed by crankd.

Sample Geeklet Refresh AppleScripts
refresh image geeklets using url location to choose which geeklets:

tell application "GeekTool"
     tell (image geeklets whose image url contains "scheme://some/url") to refresh
end tell





refresh shell geeklets using command to choose which geeklets:

tell application "GeekTool"
     tell (shell geeklets whose command contains "some command") to refresh
end tell





refresh image/shell geeklets using name (replace [type] with image or shell as required) to choose which geeklets:

tell application "GeekTool"
     tell ([type] geeklets whose name contains "Some Name") to refresh
end tell


This post is just the starting point.  I don't have time to provide support for this but I *did* want to get this out there.

Interesting Developments

I went to my blog today only to find out the DNS wasn't responding.  I went to my DNS host's site and then it hit me: they are now non-free as of January 1st and since I hadn't actually subscribed, they disabled my account!  I had gotten the email months ago but I hadn't paid attention to it.  Fortunately, they still run a free host but sadly, it doesn't offer URL forwarding :,(
As a direct result, until I get a free DNS host that *does* offer URL forwarding, heading to r0ssar00.com will *not* work, you must have the www. in front because my DNS host won't let me CNAME the root(r0ssar00.com) at all (which I'm betting is how they implement URL forwarding hence why they disabled it, AFAICT there's no technical limitation).  The CNAME is the way Google allows you to have a custom domain for Blogger, etc.

Tuesday, September 1, 2009

JS-Kit

JS-Kit clobbered my comments' CSS styles. It should be fixed by tomorrow.

Friday, July 24, 2009

Disk Spanning

If you've read my last post, you'll already have some background on the program that I'm going to use to demonstrate an awesome side effect of that particular program(mhddfs). If you haven't, read it now and then come back to this post.

This is an easy 4 step process.

This is the (hypothetical, I don't need it myself) situation: I've got 20GB of data that I need to burn to DVD(4.7GB single layer discs) and I can't find a no-nonsense tool to split up this data logically so that I can burn all of the data using as much space as possible.

Step 1: Create enough 4.7GB disk images to fit 20GB of data(around 5) and mount them. Note the paths where they're mounted at.

Step 2: Bind them all together using mhddfs.

Step 3: Copy all of the data to burn into the mhddfs mounted volume.

Step 4: Unmount all of the volumes/images and burn the contents of the images onto DVDs.

(optional) Step 5: Profit!

Problem solved.

It actually works really well for DVDs because of the way mhddfs decides where to place files. Its default behaviour is to use the next lowest priority folder when the current priority's size has reached approximately 4.2GB. Eg. You drop 1,000 equally sized files totalling 4.4GB onto the mhddfs volume(2 images, 4.7GB each. A has priority 1, B has 2), around 950 make their way to A and the rest get pushed over to B. Note that this value can be changed in the mount options so if you want to use more of the image, consult the manual page/readme to find the option(specified in bytes if I remember correctly).

Sunday, July 19, 2009

File Encryption

I've found an easy way to have an encrypted disk image that can expand it's size arbitrarily and span several discs. The really cool part: you can read each disc on it's own. Also works for any set of folders across any set of drives or even across NFS/SSHFS/etc.

A few requirements: you need to be on a platform that supports Fuse, that platform must support encypted disk images of arbitrary size.

First, grab mhddfs @ this link (an excellent google translation) and compile it. Second, grab a tool such as TrueCrypt or if you use OSX, fire up Disk Utility.

Third, create at least 2 encrypted images in the tool of your choice and using any size you want. If this is data you wish to archive to optical media, make the images to fit the media(that's what I do). Mount each image and note the path they're each mounted at.

Suppose you have 2 images, A and B, and they're mounted at /Volumes/A and /Volumes/B. You wish to mount the combined volume as AB. Open up a terminal and execute

shell# mkdir /Volumes/AB
shell# mhddfs /Volumes/A,/Volumes/B /Volumes/AB -o local,volname="AB",auto_xattr


Now /Volumes/AB contains the union of A and B and if the same file(only file, folders are merged) exists in both, mhddfs takes the version in A(the first folder passed to it, B is the second and therefore second priority). You can do this for an arbitrary amount of disc images(actually, mhddfs works on folders so if you have a number of related files spread across several folders/drives you can bind them all together into one folder).

There's only one caveat: mhddfs won't split files larger than the largest amount of free space in any one folder across all of the folders. So if all your disc images are 2GB and you drop a 2.1GB file in, it won't work. This means that any file has to be able to fit in exactly one disc image/folder. Eg: you have 2 disc images of 2GB, A has 500MB free space and B the same. Therefore, mhddfs reports 1GB free on the volume so you figure you can drop a 1GB file onto it. Wrong! This file has to be able to fit into A or B and neither have the required free space so you get an out of space error. mhddfs won't give up if the first folder doesn't have the free space. It also won't move a file to another of the source folders if that would free up enough space. In other words, it won't mess with the structure as it is. If you move a file in AB that's stored on A into a folder that's stored on B, it'll create the folder on A and move it into that.

The best part: go ahead and make another disc image, adjust the command line for mhddfs(add another comma+folder after the last one), and mount! Eg. I want to add a volume C to the union. The mhddfs command line would be:

shell# mhddfs /Volumes/A,/Volumes/B,/Volumes/C /Volumes/ABC -o local,volname="ABC",auto_xattr

A few more notes: the order you put the folders on the command line matters, mhddfs uses that to determine where to place a file. The order=priority with the first folder being 1st priority, second being 2nd priority, etc.

I've found several uses beyond encrypted disc images. I've got torrents spread across several drives because there's not enough room on any one drive(all of 'em are small drives). I've bound all the folders together into one superfolder where I can even set my client to download to. mhddfs works out the details about which drive to write to!

Props to the guy who wrote this!

Just realized this post was all over the place. I'm tired and don't wanna go back and fix it so tough.