launchd and Lingon

Well, it's about time I wrote a post about launchd. launchd is the new catch-all services launcher in Tiger. It's the thing that makes everything you need in order to do anything on your computer launch, either at boot, or at the appropriate time. It's got some real problems and limitations right now, but hey, it's new. And there's plenty good to say about it, even in this early stage.

I won't go too much into how launchd works nor all of what it does. But if you want to get an idea of what services have been moved to launchd from other parts of the system, take a look at the files in:

/System/Library/LaunchDaemons

Here you'll find a list of preference files, or .plist files. These files are all named for services that used to be started and handled by init and other such UNIX daemons and config files. Among the most notable in this list are the periodic maintenance jobs once handled by cron. These, too, have now been taken over by launchd, though cron remains available for scheduling other jobs. For now.

Anyway, this should give you a good enough idea what launchd does. If you're really lost here, I suggest you do some homework. There is a great overview of launchd, complete with tutorial, over at AFP548. There's also a good launchd Developer document at Apple's Developer site. Between these two you should be able to get largely up to speed on launchd. And if all this services stuff is way over your head, well, just move along please.

One of the coolest features of launchd, though, is the fact that it is easily user-configurable, and user-specific. That is launchd items, or LaunchAgents and LaunchDaemons as they're called, can be placed in the user's home account and run on a per-user basis. The other remarkably cool feature of LaunchAgents and Daemons -- and the one I really want to talk about -- is that they can watch folders and/or files. These two features allow for a degree of conditional automation -- and by that I mean, If/when user does A, then System does B -- previously undreamt of on a Mac. Well, that may be an overstatement, but launchd will certainly make such customization a great deal easier. And it's not even that hard to use, once you get the hang of it.

If you check out the AFP548 demo, they have you create a LaunchDaemon that watches a folder for modification, and then, if the folder is modified, launchd automatically moves the items of this "watch folder" (and, yes, that is the technical term) to a new destination folder. Already you can see where this would be extremely useful for backups or versioning systems, or any kind of synchronization of files. The idea of the watch folder/file is remarkably powerful. You can have launchd run any shell script, AppleScript or command anytime any file or folder is changed. In our lab we were, at one point, using launchd to watch our list of automount user mounts, and automatically reload the automount daemon whenever a new user was added to the list. You could (and I may, at some point) make a launchd item that detects the mounting of external hard drives, and then runs a script to disable Spotlight on said drives. There are a million things you can do with this one feature alone. But to do any of it, you must know how to edit those pesky .plist files.

Being no stranger to editing XML .plist files, I started off the hard way, editing them by hand in a text editor. I then graduated to the Property List Editor included with the Developer Tools. But recently, I found an excellent and free utility called Lingon, which takes a lot of the grunt work out of creating LaunchDaemons and Agents. It even comes with an "Assistant" to help you get started creating your first LaunchDaemon. And it will blessedly load your items into launchd, so trips to the command-line and the arcane syntax of lines like this:

launchctl load -w /Volumes/Work/systemsboy/Library/LaunchAgents/com.systemsboy.LA01

become a thing of the past.


Lingon: Launch Your Dreams Right Here!
(click for larger view)

So, okay, sometimes a GUI is a great thing. No offense to the Lingon guys and/or gals, but I'd really love to see Apple include a front-end to launchd sometime in the future, so that it could be really accessible to mere mortals without all the fussing around. Until then, Lingon makes a great addition to any Admin's toolbox who might have need of the sort of auto-magic attainable with launchd.

I do want to note one more thing. It's possible to seriously lock up your system with LaunchDaemons and Agents. To wit, I somehow created a LaunchAgent that perpetually opened one of my hard drives. This, for all intents and purposes, prevented me from accessing any application but the Finder. In fact, I couldn't even navigate the Finder to remove the item as every time I tried to do anything at all, the window to the drive would open and take over the system. Nor could I easily access the offending LaunchAgent via single-user mode, as my home account is stored on a second partition that is not mounted in single-user mode. Fortunately I keep a secondary user account for just such emergencies. In the end, I was able to unload and delete the offending LaunchAgent via this secondary account. So just a word to the wise: Use launchd with care. And keep a secondary account handy, just in case.

And one last thing: Hats off to the Tiger devs. I bitch a lot about 10.4, but launchd is a keeper. One of the best hidden surprises to this new OS.

Cool Mail Feature

Just a quickie: I just discovered a feature in Mail.app that I was completely unaware of. It is possible to save Mail messages as .rtf (rich text) files. Just open or highlight a message, and click "File->Save As..." But the niftiest thing is that you can save multiple mail messages in one .rtf file. Just highlight a group of messages, by command- or shift-selecting them, and again, "File->Save As..." The file you save will contain all the messages you selected, complete with email headers and all.

And just so you know, you can also save your messages in Plain Text (.txt) or Raw formats.

Neat-O.

Firefox Update

So, I've been using Firefox as my default browser for about a week, both at home and at work, and I thought I'd report a follow-up on the experience. So far, it's been completely positive. As I stated earlier, Firefox does indeed rock. I have not had a single crash or had a single site fail to load (the latter happened to me all the time in the most recent incarnations of Safari). Firefox is fast and responsive. My window positions are remembered after quitting the app. Editing blog posts works as it should. And I have become addicted to certain features offered by Firefox that simply don't exist in Safari.

Surprisingly, one of the most addictive and useful features is the ability to mouse-wheel-click on a tab to close it. Safari gives you a little "x" in each tab, which when clicked, closes the tab. Firefox only offers an "x" for the tab you're currently in. So at first glance, there's no apparent way to close other tabs. But mouse-wheel-clicking a tab does the job, and requires far less accuracy than Safari's "x" method. There's a lot of stuff like this in Firefox. Hidden stuff that you thought only existed in Safari, but actually does exist and in many cases is implemented better, in Firefox.

Another feature I love is the ability to rearrange tabs. This is something I don't often need to do. But when I do want to do it, boy is it nice. And, going back to Safari, I really miss this feature.

Another feature I really like, and which I'd swear was promised long ago in Safari, but never implemented and seemingly dropped (apparently in deference to "features" like the inability to properly load multiple pages at one time) is the ability to bookmark a group of tabs. I tend to use tabs to group articles by a particular category I'm researching. Say, NFS. I'll Google NFS, then open each article of interest in a new tab, and start reading, closing the useless articles as I go. What I'm often left with is a group of tabs I'd like to bookmark in a folder called something clever, like "NFS." To do this in Safari, I'd first have go to the bookmarks window, create a folder called "NFS," then go to each tab and bookmark it. In Firefox, I hit "control-shift-d," name my folder, and I'm done.

The page-find feature is another great implementation in Firefox. It works similarly to Safari, in that "command-f" brings up a find dialog, but in Firefox, the dialogue pops up at the bottom of your window, instead of on top of everything. It stays active 'til you're done with it, and includes a great "highlight all" function that will highlight every instance of the term in your browser window. The highlight is especially nice too, as Firefox uses its own, can't-miss-it green for highlighting results on a page. Safari uses the system highlight color, which is often too pale to locate on a busy webpage, no matter what color I use.

My major complaint -- and it's quite minor -- is that Firefox doesn't quite look as nice as Safari. Safari looks a little better. A little more Mac-like. It's true. You can do a lot to improve the appearance of Firefox. I'm using a theme called "GrApple (Eos)" and it looks very nice. I'm also using "fancy widgets" from Empty Spaces which I installed with Firefoxy. And it looks pretty damn good. But Safari just barely edges it out in the appearance category. Just barely. My one other complaint is that the Cocoa Dictionary function (hover over a word and hit "command-control-d" to see a definition straight from OS X's built-in dictionary) doesn't work, since Firefox is a carbon app. But these are minor quibbles and are largely overshadowed by all the great features I gain from using Firefox.

I've loved Safari for a long time. It's an Apple app to its core. And as such, one tends to see a trade-off between simplicity and functionality. That is the Apple way. I guess for me, I've moved beyond what Safari can offer at this point in its development history. Safari is a great browser, especially for users without a lot of specific needs, or who don't, like I do, tend to spend all day surfing the web and using web apps. It's a great beginner's browser, and understanably inspires fierce loyalty in the Mac community. But for those of us who need a more robust browsing experience, the latest version of Firefox* kicks some solid ass. And it's only an alpha.

Until Safari catches up to Firefox's feature list, consider me switched.

*Previous versions of Firefox, for whatever reason, did not hold up so well for me as this latest release.

Feed Readers: I Don't Get It

RSS feed readers are all the rage these days. Safari even now has a feed reader built-in. But most people aren't happy with this. So dedicated feed readers abound. I've tried a few, and I can honestly say, I just don't get it.

Basically, these feed readers -- applications like NewsFire and the ever-popular NetNewsWire -- are browsers for reading nothing but RSS feeds. Essentially, they present a list of feeds to which you've subscribed in one column, a list of articles aggregated as-you-like-them in another, and, finally, the full page of any article you happen to select in a window. Neat, right? I guess.

But what I do is to keep a bookmarks folder with my favorite blogs in Safari. I open that folder in a set of tabs, and I start reading. And that's it. It's that simple. I don't see why I need a feed reader to do this. What's the advantage of having all these feeds in a separate application?

One thing people seem to like is that the feed readers can tell you which articles you've read and which ones you haven't. But I already get this information from the regular web page in Safari. You know how I know whether or not I've read a given article? Simple. I remember. I don't really need an app to tell me this. I'm pretty smart that way. Another feature of the feed readers is that they'll alert you to new content. But I check my blogs daily. I'm already pretty aware when and if there's new content. And I don't need to be constantly pestered about new stuff, or constantly fed information. I'll take my daily dose, thanks. Every ten minutes is too obsessive, even for me, and that's saying a lot.

So these RSS feed readers come across, to me, as either crippled or repurposed browsers. Even the RSS reader in Safari seems pointless, though at least with it, I'm already in my browser of choice and don't have to go switching apps. Ironically, in the dedicated readers, clicking links usually takes me to my browser of choice anyway. So why not just start and finish in the browser? This business of apps opening other apps because they can't really handle everything on their own has always struck me as kind of dumb. Like in Quicktime, for instance: The idea that you can have URL links in Quicktime movies is cool. But it seems to me to work best from within the browser itself. Standalone Quicktime movies that take me to the web -- to a browser -- are stupid and irritating, and that's why no one uses them. (Well, no one but Apple, and that's just cross-marketing.) I mean, I opened Quicktime in the first place to use Quicktime, not to surf the web. Going that direction generally doesn't work: Browsers handle Quicktime content just fine, but Quicktime is a sucky environment within which to surf the web. I feel pretty much the same way about RSS news aggregators: Why use one when you can already get everything done right in the browser?

This, by the way, is why there's such a huge in interest in browsers, why browsers are so important. Browsers are the window to the world wide web, precisely because they're designed to handle any kind of media you can throw at them. Quicktime, iTunes, and in my opinion, news readers are not. All those apps open browsers to get the real work of surfing done. I guess my point is, we don't need these news readers; what we need are better browsers, though frankly, most browsers still kick the crap out of even the finest dedicated news aggregators.

But what I'd really like is for someone to explain this to me. It's quite possible I'm just not getting it. Can someone shed some light on the usefulness of RSS feed readers for me? People seem pretty passionate about these readers. So what's the deal? Am I just being shortsighted? Can anyone explain to me why I would ever want to use one of these things? Or why there's such a craze over them lately? Anyone?

I'd really like to know.

Firefox Rocks!

Holy Sweet Bejeezus!

In my recent browser review, I gave the latest Firefox release (which has since gone to 1.5b2) the praise it deserves. It's really gotten quite nice. It's speedy, it looks great, and -- it's main selling point -- it does everything you could ever want a browser to do. My one real complaint was the key-commands, particularly for switching between tabs. It seemed to have reverted to an earlier version -- "control-page up" -- which is both a clumsy two-handed key-command, and which requires a whole different set of keystrokes on a Powerbook, and so is quite worthless as a key-command, which is supposed to be easy to use and to remember.

After the review, a reader, pablo7, suggested I investigate extensions for Firefox, particularly one called keyconfig, which is meant to allow user control over key-commands. Well, I appreciate the tip, and I finally got around to looking at keyconfig, and, unfortunately, it would not install because of a "download error." Still, this spurred me on to investigate the matter further, and I ended up checking the "Firefox Help" pages from the application's Help menu (which, by the way, look great, and are actually, as we'll see, quite helpful indeed). Lo and behold, not only are there additional key-commands for tab switching, there's actually a quite sensible one: "command-option-arrow." Same as Camino.

Firefox's Help Menu Actually Helpful
(click for larger view)

I'm actually almost positive I tried this combo before writing my review (though maybe I didn't), so it may be new to version 1.5b2. But it may also ultimately be the straw that breaks the camel's back in this case. I've been increasingly fed up with Safari, and increasingly pleased with Firefox . And this beta's been rock-solid in my tests, and much more useful when logging on to web-based accounts. I even keep finding other great features: arrange-able tabs, the ability to bookmark tab groups, very configurable popup blocking, and it will even import Safari's bookmarks, cookies, history and preferences. Oh, baby! That's what I like.

So, I'll say again: Holy Sweet Bajeezus! I may be switching to Firefox. Like, soon.

Safari, this is your last warning.

UPDATE 1:
Here's the best Safari-like theme I've seen for Firefox, and it works in the latest beta.

Also, a decent read on some of the cool things you can do with Firefox. Though it pertains to the non-beta version (and redundantly mentions tabs first off, as if other browsers lack this feature, or like any Mac user is still using IE), much of this will work in the beta, or will work when v.1.5 comes out of beta. And really, it's just an overview. This is the most freely configurable browser out there.