Safely modify Apple's Widgets

If you’re reading these Friday blog entries, chances are you’re a tweaker—you like to explore your system, make changes to things, and see what you can do beneath the hood. That’s a good thing, as it’s a great way to learn about your system. But it’s also a great way to break it, if you do something wrong. So we try to always remind you to make a backup before making any changes, so that you can easily undo something you might have done.

One area of OS X 10.4 that’s ripe for tweaking is the Dashboard. Widgets are just collections of JavaScript code (to run the app) and CSS stylesheets (to control how they look). As a result, modifying these widgets has proven both popular and relatively easy to do. We’ve published quite a few such hacks over on the macosxhints.com site—everything from how to replace the Address Book’s mapping service to personalizing the World Clock widget to changing the colors of the Stickies to adding more airports to the Flight Tracker. Please note that if you’re going to attempt some of these, they aren’t covered in the level of detail you typically see in my blog entries here—so you should be fairly comfortable in the Terminal and text editors before proceeding. (We’ll probably cover some of those, or other similar hacks, in detail in future Friday blogs). And as noted above, make a backup first!

Today’s tip is a quick way to backup widgets you want to modify. Typically, you’d do this by just dragging a copy of the widget from the top-level /Library/Widgets folder to another location. If your altered widget failed to work, you could just replace the modified one with your backup. But thanks to the way OS X’s hierarchy of folders works, there’s a much simpler method.

Instead of copying the widget to your Desktop or other safe location, copy it to your user folder /Library/Widgets. Note that you may have to create this folder first if you haven’t installed any third-party widgets. Now, instead of changing the original, alter the copy in your user’s folder. When you’re done, launch Dashboard, and you’ll find that when activate the widget, you’ll see the customized local copy, and not the system-wide version. It remains on the disk in its original unaltered state.

This works because when Dashboard goes looking for widgets to load, it looks in your personal Widgets folder first and then proceeds up to the top-level Widgets folder. If you have duplicate widgets, OS X ignores the ones in the top-level folder since the user folder versions are already up and running.

This is a great way to safely modify widgets, put the modified versions to use right away, and yet leave the Apple-provided widgets in their original unaltered forms. Slick!

Subscribe to the Best of Macworld Newsletter

Comments