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 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
Posted by JohnnyAppleseed | Under Configuration, Programming, Software
Wednesday May 7, 2008
One of the things that you probably look at a lot more often than you realize is the time display in the top menu bar. If you came from a Windows environment, you may have tweaked out that display to show you the date and/or the day of the week. Apple seems to think it’s sufficient to let you see the time, and if you can figure out how, the (abbreviated) day of the week. We just happen to like having a bit more information available at a glance:

Above you see our top menubar time display, along with the dropdown menu you get if you right-click on that display. As you see, we show the day of the week (non-abbreviated), the full date (again non-abbreviated), the time complete with seconds, and an AM/PM indication (by the way, it’s only highlighted blue like that because we have the dropdown activated - usually it’s the normal black text on the semi-transparent background). As you may have guessed, we have a wide screen display - were it a regular display we might try to conserve a bit more space, but as it is we have enough screen real estate that we can afford to have the display the way we want it. But, you may be wondering how we did it - if so, that’s the purpose of this article.
To begin with, click on “Open Date & Time” in the dropdown shown above. That will open this preference panel (you might have to click on the “Clock” tab at the top):

In this panel, check the options shown above and any others you want EXCEPT for “Show the day of the week” - if you check that, you’ll get an ABBREVIATED day (e.g. Mon Tue Wed etc.). We are too OCD around here to want to stare at an abbreviation, we like seeing the word spelled out! While you’re in this panel, click on the “Date & Time” tab and the display will change to this - make sure you have selected a server and that you have checked the box to set date & time automatically.

We would just point out that if you have another machine acting as a timeserver on your local network, or you prefer to use a non-Apple timeserver, you are perfectly free to enter the address into the text field (this example shows using another machine on your local net as a time reference):

Anyway, see the button at the bottom of that panel labeled “Open International”? You need to click on that now, which will bring up the International preference pane. Select the “Formats” tab and you will see this display:

First note that the Region is set to “Custom” - we don’t remember doing that, and think that it probably changes automatically once you start customizing formats, but just keep in mind that it probably does need to be set to “Custom” for this to work. Now, note the two “Customize” buttons in the Dates and Times sections. We’ll show you the Times section first, so click on the LOWER “Customize” button, so we can show you how we constructed our date and time string. On the panel that appears, be sure to select “Medium” in the “Show” dropdown, because this is the format the menubar display uses (and just about nothing else uses it, as far as we can see):

Unfortunately our string is a bit longer than the display allows, so in order to let you see it all, here’s the same display but with the cursor moved all the way to the right:

When you first enter this panel, it will show you the current time format, except that if you checked the box to show the (abbreviated) day of the week, that will not appear here. What you want to do is insert the elements you want to use to build your date and time string, as we have done. You can drag any of the elements in the bubbles from the list shown, and you can insert normal punctuation such as commas, colons and spaces. But as you may have noticed, we have “bubble” elements that don’t appear in the panel! Where did we get those? Well, if you back out of this panel to the previous one (”international” panel, “Formats” tab), then click on the FIRST “Customize” button (in the Dates section), and then select “Full” from the dropdown, you should see this panel:

Now, here’s the trick. TEMPORARILY drag the date elements you will need into the text field - you don’t have to remove the ones that are already there, just drop these after the existing string. Then use the mouse, or the shift+arrow keys, to highlight just the elements that you temporarily dragged into the field. Press Command-X to “cut” (copy and delete) those elements, leaving only the original format string (if you make a mistake at any point in this process, pressing Command-Z should undo the last thing you did). Now back out of this panel and click the “Customize” button for the Times section again - once again make sure this dropdown shows “Medium”, then use Command-V to paste the copied date elements into the time string! If they aren’t in the correct order you can highlight each individual item and drag it around until you get it right. Insert any desired punctuation (commas and spaces) and you should be good to go.
It is a little tricky to position the cursor properly during this process (between the “bubbles”), so don’t get too frustrated, just realize that it’s tricky for everyone and you should get it in a few tries, and remember to use Command-Z if you make a mistake.
We do realize that someone will probably want to point out that the latest version of iCal displays the current date on its icon in the dock, but we like to see our date and time information in one place at a glance, not have to search the dock for the iCal icon!
Uber-geek tip: The actual menubar time string format definition is stored in the file ~/Library/Preferences/com.apple.MenuBarClock.plist, and if you knew the correct format you should (theoretically) be able to change it in that file only, with changing the “Medium” time format for other applications. But unless you are a true geek (or like to live on the edge) we don’t recommend attempting to manually edit that file, because you could really mess up your menubar clock. If you simply must try to do it that way, at least please back up the file someplace safe before you start messing with it, so you can restore it if your edits really mess things up!
Related posts