CrabApple Forest
The Orchard of Mac Knowledge!
Please Visit Often!
Posted by JohnnyAppleseed | Under Configuration, Review
Wednesday May 14, 2008
As Apple describes it, “Folder Actions is a feature of Mac OS X that lets you associate AppleScript scripts with folders. A Folder Action script is executed when the folder to which it is attached is opened or closed, moved or resized, or has items added or removed. The script provides a handler that matches the appropriate format for the action…..”
What they are saying is that by setting up a Folder Action, you can run a script whenever any of the following occur:
- the attached folder is opened
- the window of the attached folder is closed
- the window of the attached folder is moved or resized
- items are placed into the attached folder
- items are removed from the attached folder
What we’re going to show you here is how to use a folder action to make a folder that, when you drop an image file into it, will attempt to convert it to another format, in case you like to save all your images in the same format.
To start with, in Finder go to the location you want to create your “Drag and Drop” folder and right-click and select New Folder:

Rename the folder as you like (we called it “Convert to PNG”) and then right-click on the newly created folder and select “Enable Folder Actions” (note that you may have to navigate through the “More” selection, as shown here):

Once you have done that, right click on the folder again, and this time select “Attach a Folder action…”

A file picker will appear - you want to navigate to /Library/Scripts/Folder Action Scripts/ (note this is off your primary drive’s root folder, not your user folder) and then click on Choose:

Once you’ve chosen the Folder Action Scripts directory, choose the actual script to associate with the folder. In this case we’ve chosen Image - Duplicate as PNG.scpt:

Now drag an image to the folder that’s not already a PNG (such as a GIF or JPG) and it should be converted to PNG. The original is not deleted, so you should find both inside the folder. As you may have noticed, there are also scripts that will “Duplicate as JPEG” and “Duplicate as TIFF”, so the possibilities exist to make “Drag and Drop” folders for those formats as well.
This just scratches the surface of what Folder Actions can do. Apple’s site has a section on Folder Actions, including a page showing how you can write your own Folder Action Scripts, and descriptions of the Folder Action Scripts found in /Library/Scripts/Folder Action Scripts/.
Apple’s site also has a couple of additional Folder Action Scripts that you can download and use if you wish. They are:
Archive Added Items - This script will make an archived copy, in ZIP format, of the individual items added to the attached folder. Archived files are placed in folder named “Done” within the attached folder.
Auto-backup Script - This script will automatically backup specified items any time a particular hard drive is mounted on the desktop.
In addition, if you search the web you can find other Folder Action Scripts that people have created.
We would be remiss if we did not mention that this is the Apple way to do things, and it’s always possible to do things differently. For example, in an article entitled “Use launchd to replace folder actions” at Mac OS X Hints, the author of that article notes that “Folder actions are quite slow, and on 10.5.x, I found them to be not really fun to play with. Another way to watch a folder is to create your own launchd script.” He then goes on to explain how to do that, though admittedly we didn’t quite follow what he was doing. He still winds up calling an AppleScript, but he uses a launchd script to actually watch the folder, and since our most recent previous article was about Lingon, which assists in creating launchd scripts, we thought we’d at least mention it so that the “true geeks” could try their hand at using that technique. As for us, we probably aren’t going to care all that much if it takes the Mac an extra second or so to notice that we dropped something into a folder!
Related posts
Posted by JohnnyAppleseed | Under Configuration, Programming, Review, Software, Utility
Sunday May 11, 2008
Lingon is one of those tools that at first blush may seem to be something only a true geek would love, but it’s actually fairly practical. What it does is to allow you to launch scripts or programs according to certain criteria. If you have previous experience with Linux or Unix, you can think of it as a way to set up something similar to a cron job, except that you have more flexibility.
One thing you can do is set up scripts or applications to launch at startup. Now, you may already know how you can launch applications at startup - you go into System Preferences, click on Accounts, and then (while your account is selected) click on Login Items. Once there, you can add or remove applications you want to launch at startup by using the + and/or - buttons. And, that’s the preferred way to launch an application at startup for the logged-in user.
But what if you want to launch an application based on some other criteria, or you want to launch a script of some kind? What if you need an application to start no matter which user is logging in? Or, what if you want to tweak an existing startup item that’s run by the system (as an agent or a daemon) and not by a particular user? That’s where Lingon comes in. Lingon lets you edit and create configuration files for launchd (and maybe you are asking, what is launchd? Well, according to Wikipedia, “launchd is a unified, open source service management framework for starting, stopping and managing daemons, programs and scripts.” Aren’t you sorry you asked?).
To give you an example of how Lingon can be used, we set it up to start the CallerIDpop perl script from the Michigan Telephone, VoIP and Broadband blog. This is a script used with Linksys/Sipura VoIP adapters (and some phones) that, when there is an incoming call, provides a Growl popup showing caller details and the time the call was received (it can also write this information to a log file). Previously we had been using their suggested method of running an AppleScript (saved as an application) at startup, the AppleScript containing the line that actually starts the Perl script. Although this works, it’s a fairly convoluted way to do it and it seems to eat up a lot of system resources. So, we set out to find another way to invoke the script at startup. Here’s how we did it using Lingon (which, by the way, seems to get the script running a lot quicker, and the script itself seems to be running in a more stable environment):
When you first fire up Lingon, you get this screen:

Click the small button labeled “New” (with the + on the button) in the upper left-hand corner, and you get a dropdown as shown here:

We selected “My Agents” because we only have one user account on that system, and didn’t really want the script to have root privileges. You should think long and hard about running anything as a daemon, because if anything goes wrong (whether due to programming error or malicious intent) the script will be running as root and can do just about anything to your system. Having selected that, we got this window:

As you can see, everything is fairly straightforward. In section 1 you give the agent a name, in section 2 you insert the command just as you would enter it if you ran it directly from a terminal window (or you choose the application to run, if you are running an application), and in section 3 you pick the options you want to use to trigger running the script or application. If you’re not sure about any of the options, click on Help (in the top menu bar) and then “Lingon Help” and it will bring up a PDF file in Preview that explains how to use Lingon. The Help menu also gives you access to the man pages for launchd.plist, launchctl, and launchd, in case you are making changes in any of those files.
Note the “Expert Mode” button in the lower right-hand corner - this shows you the actual XML code, and allows you to write keys and values directly if you are comfortable doing that.
Don’t forget to click the “Save” button at the top when you are finished - we forgot to do that and had to start all over! We sort of wish that the “Save” button were underneath the other three sections, maybe in a section 4!
Unfortunately, to make everything work properly you’ll have to log out and login again, or reboot your Mac, as Lingon will remind you:

Not only can Lingon be used to make your own script or application launchers, but it can also be used to edit existing system agents and daemons. While you normally shouldn’t do this, if you know what you are doing it can sometimes improve system performance. On the other hand, if you don’t know what you are doing, you could render your system totally inoperable! As an example of why you might want to do this, we recommend you see the article, “The Case of the Slow Mac (and how to fix it)” at Maciverse. If you think that your Mac is running a bit sluggish, or if you’re seeing the “spinning beachball of death” a bit too often, this article explains one possible reason, and a suggested fix that’s much easier to make if you use Lingon.
Related posts
Posted by JohnnyAppleseed | Under Games, Review, Software
Friday May 9, 2008
The deal here is that you can go and download this free game called Cubes, which comes in Mac and Windows versions. The company behind it offers several other games but most of them are not free, and you can’t tell which are free and which are not from the main page. You should assume that if you are downloading a demo version of one of their games, you’ll only be able to play a limited number of times. We suspect that Grass Games is giving away Cubes in the hope that you’ll come back and perhaps download something else and buy it (and this is reinforced by the fact that you see an ad for another of their games when you exit Cubes), but as far as we can tell you can play Cubes as often as you want without payment or registration.
So, what is Cubes? It’s a falling brick game - in other words, it’s whole lot like a very popular computer game of Russian origin, that’s been around for at least a couple decades now. The game is highly configurable and has more options than you might expect, and while we couldn’t find any documentation, the effects of most options are fairly obvious. The nice thing is that you can pick the screen resolution you want the game to run in (up to 1920×1200!) and run it in full screen mode, or in a window (interestingly, there seems to be a bug where you have to select your desired resolution while full screen mode is selected, and only then switch to windowed mode). If you run it in full screen mode, the effect is much like playing on an arcade machine, except that the sound of your Mac’s fan screaming may alert you to the fact that your CPU is being pushed to the max (unless maybe you have a newer multi-core system). You can mitigate this somewhat by going into the options and under the “MISC” section, set the “PROCESSING POWER” to a lower value.

Our screenshot (showing the options selections) don’t really do the game justice, because we selected a low screen resolution to minimize page download time. They could have used a typeface that renders a bit better, but it’s not as cramped as it looks here if you’re using a decent screen resolution. Not that it matters when you’re playing the game - you’re looking at colored falling bricks, which could probably be successfully rendered on an old Apple II, though the overall effect wouldn’t be nearly as good as what you are getting here.
We do wish this game didn’t monopolize the CPU quite so much (we watched the Activity Monitor during one run in Windowed mode and Cubes was far and away the biggest user of CPU power, even making Firefox look like a lightweight), but then we did play it quite successfully on a dual-core Mac Mini without any apparent problem (well, except for the fact that Big Crab stinks at these kinds of games!)
Related posts
Posted by JohnnyAppleseed | Under Configuration, Review, Software, Utility
Thursday May 8, 2008
Every so often we like to call your attention to some cool Mac-related articles, even if we didn’t write them. In this case, the articles cover a couple of ways to explore your Time Machine backups, and both of them are from the folks over at TidBITS. The first, “Prune Your Time Machine Backups Selectively”, tells you how to use a modified version of GrandPerspective to see which files are hogging space in your Time Machine backups. If any of these are files that don’t need to be backed up, you can exclude them from your Time Machine backups to make additional room for the files you do want to preserve.

The second explores a new command-line utility called tms, which is coincidentally enough written by Robert Pointon, who is also the author of the fseventer program that we reviewed previously. That article is called “Time Machine Exposed!” and it explains how you can use tms to get much more information about your Time Machine backups than has hitherto been available.
Now, we are not usually a big fan of command-line hacks here in the CrabApple Forest - if we’d wanted to use the command line we’d have stuck with MS-DOS! Mac users (moreso than, say, Linux users) seem to appreciate the value of a good Graphical User interface (GUI). So we are sort of hoping that either Mr. Pointon or someone else will write a GUI “front end” for tms sooner or later. But in the meantime, those of you who are into doing things from the command line, along with those who simply want to be able to delve into your Time Machine backups and find out “what’s in there”, will surely appreciate the information contained in the above-mentioned two articles.
Related posts
Posted by JohnnyAppleseed | Under Configuration, Review, Software, Utility
Thursday May 8, 2008
Those used to downloading files and software intended for use on Windows-based machines know that there are a wide variety of compression formats out there. Mac users have it a bit easier - it is very rare that you will see a file intended for use with a Mac compressed using anything other than the zip formap. The main exception is that once in a while you’ll get a file with a .tgz extension, which is a compressed Unix tarball, but that’s fairly rare. The main reason for the standardization of the zip format is that it’s the format the Mac uses natively, for example when you right click on a file or folder (or a group of files and/or folders) in Finder, and choose the “Compress” option.

Compressing files saves a lot of space, but one drawback has been that you can’t use Spotlight to find the file within the archive. However, one interesing thing about Mac OS X is that you can extend its capabilities by using plugins. Bartas Technologies offers Ziplight, a freeware Spotlight importer plugin that lets you use Spotlight to find files within zip archives.
We know of only two limitations with this plugin. The first is that it only works under the Tiger or Leopard versions of OS X. The second is that Ziplight will only search the names of the files within a zip archive, not the actual contents (so you can’t search for a text string within a compressed file, for example) - it would take far too long to uncompress every file on every volume on your system, in an attempt to find the searched-for string. But if you know the file name (or a significant portion thereof), and you have installed this plugin, Spotlight should be able to find it for you.
Installing Ziplight is easy - double click on the .dmg file, agree to the license terms, then view the included “Read Me.pdf” file for installation instructions. If you’re new to the Mac you may not quite understand what they are telling you to do, so let us break it down for you. You have to drag the Ziplight plugin (the Ziplight.mdimporter file from the disk image), but since it’s a plugin and not an application, you do not drag it into your Applications directory. Instead, you drag it into a particular directory specifically intended for Spotlight plugins. Easy enough, except there are two such directories on your system - /Library/Spotlight and ~/Library/Spotlight/ (the first is off the root directory, the second off of your user home folder).
If you install the plugin in ~/Library/Spotlight/ it will only be available to you, not to any other user on your Mac. This is probably not what you want (even if you are the only user of your Mac), so we’d suggest dragging the plugin file to the /Library/Spotlight file off the system’s root folder. That will make it useable by all users on your system, plus we think it’s probably better to keep all your Spotlight plugins together in the same directory.
Note that you will need to restart your system, or at least logout and then log back in, before the plugin will become active - and after that it will take some time for Spotlight to index all your zip files. We do wish that maybe there was a way that it could take a bit more time and index the contents of those files (after all, since it’s doing it as a background task, it’s not like it’s under a time constraint) but we’ll take what we can get, and having the ability to find filenames within zip files can be downright handy at times.
There are many other available plugins that can extend the capabilities of your Mac. For example, there is a whole page of plugins that will extend the capabilities of QuickLook, which are installed in a very similar manner (they go into a different directory than the Spotlight plugins, but install just as easily). As you become more familiar with your Mac, you’ll almost certainly want to install more of these little helpers that make OS X work smarter!
Related posts