Toubabou

August 16, 2007

Hacking Apps

Filed under: Uncategorized

Well, I’ve been sort of sitting on this one, so I should finally get it over with. One of the beauties of Mac OS X is the things that are under the hood that make it just work. In this case, I discovered that I wanted to have two copies of an application, but with different preferences for both of them. Now, some applications will let you create separate locations, or whatever, but most don’t. The first example was a hacked Terminal that I used for Visor. In that case there’s the additional step of setting the preferences in Terminal, and then copying the file and renaming it.

Somewhat easier was my hack of the excellent weather program, WeatherDock. I wanted to display two icons, for two different cities, but this isn’t currently supported in the program. So, I made a copy of the program, opened the package contents, and started digging.

The first thing to do is to edit the plist file. I like to use the Property List Editor that comes with the Developer Tools, but anything that can open/read/write XML will work. The CFBundleIdentifier for WeatherDock is called nl.alwintroost.WeatherDock. I changed this by adding the name of the city whose weather I wanted displayed: nl.alwintroost.WeatherDock.hacked.

The second step is optional, but it makes it easier to find the process id for the hacked version, if you need it. I changed the CFBundleExecutable string to read WeatherDockHacked. This won’t actually work unless you also change the name of the file in the Contents/MacOS/ from WeatherDock to WeatherDockHacked as well. At this point, if you want to change the icon for the program, as I did for Visor, you can either replace the icon graphic in Contents/Resources, or you can put in a new icon file, and change the value of CFBundleIconFile. I think you’re starting to get the idea.

If you’re really uptight you could go into Contents/Resources/English.lproj (or the folder appropriate for your language) and change the name of the WeatherDock help folder to something like WeatherDockHacked help, keeping in mind that you’ll need to change the value of the CFBundleHelpBookFolder to the same value.

That’s it. the preferences file is now called nl.alwintroost.WeatherDock.hacked.plist, and any changes you make will only be reflected by the hacked application. In the case of Visor, where Visor has no Preferences menu option, you need to edit the preferences of Terminal, quit, and then rename the preferences file to your hacked ID - in my case com.apple.hacked.Terminal.visor.plist

Comments »

The URI to TrackBack this entry is: http://toubabou.blogsome.com/2007/08/16/hacking-apps/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.

Get free blog up and running in minutes with Blogsome
Theme designed by Jay of onefinejay.com