June 2018
Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Helium Foot Software develops MercuryMover: Don't let the mouse slow you down! Move and resize windows on your Mac with the keyboard.
Recent Entries
GroceryList and Beyond(04/18 11:26)
Go, Go, GroceryList(01/28 22:53)
Indie+Relief(01/19 23:13)
One Fifth of a Five Fingered Discount(11/06 11:18)
On the Job, On the Train(10/30 13:09)
Hey Mac(10/21 11:38)
Dog Fed(10/15 10:53)
20 Questions(10/08 10:59)
A Gallon of Milk and an Onion(10/06 12:34)
The iPhone Doesn't Need Me(09/24 12:46)
Recent Comments
Recent Trackbacks
There are no trackbacks.
Helium Foot (28 items)
Software (5 items)
MercuryMover (37 items)
Blog (3 items)
MacSanta (3 items)
Marketing (12 items)
Philanthropy (2 items)
Podcasts (3 items)
Highbrow (3 items)
iPhone (1 items)
GroceryList (4 items)

Syndicate this site (XML)

RSS/RDF 0.91

05 October


Where Keith finds the default app

In this tweet yesterday, John Gruber of Daring Fireball fame asked:

Anyone have a shell or AppleScript command that tells you what the current default web browser is?
I had written code to do this for my upcoming app, so i spent a few minutes packaging it up as a command line tool. I present to you defaultapp. Download it here. The zip file contains the now public domain source (not too pretty) and the "defaultapp" executable. To use it, give it a -n, -b, -p or -a and a document extension. The options (in order) yield the app's name, bundle id, path or all three. Thus:
$ ./defaultapp -n html
$ ./defaultapp -b html
$ ./defaultapp -p html
$ ./defaultapp -a html
The tool uses LaunchServices to determine url of default app for the given document extension and then LaunchServices again to find the application name. The bundle id is determined via the carbon CFBundleCopyInfoDictionaryInDirectory call. You can probably do this with Cocoa, but i found the carbon call to be more reliable. YMMV.

Posted by kalperin at 17:07 | Comments (7)
<< MercuryMover v2.0 | Main | Hacking the Press >>
Re: defaultapp

CFBundle is CoreFoundation, not Carbon.

Posted by: d at October 06,2008 19:51
Re: defaultapp

The default web browser isn't necessarily the default opener of .html files, though.

Posted by: Jonathan Lundell at October 06,2008 21:23
Re: defaultapp

Nice. Only thing that would make it better is if there was a default behavior if no option is specified (my vote is for -a).

Posted by: Arden at October 07,2008 04:06
Re: defaultapp

IC-Switch not only tells you what the default application is selected, it allows you to change quickly and easily your default emailer, FTP client, news and RSS readers and Web browser. Quick and easy way to change default application for testing purposes.

Posted by: Diane Ross at October 07,2008 20:17
Re: defaultapp

To be able to change this from the command line:



Posted by: Preston at October 08,2008 17:24
Re: defaultapp

Nice. I've incorporated this functionality into duti 1.4.0 (using CF equivalents). Thanks, Keith.

Posted by: Andrew Mortensen at October 15,2008 16:14
Re: defaultapp

Ok, thanks a lot for your post. It was of good help to me, hope to hear from you soon again.

Posted by: rapid4me at December 25,2009 03:43
Post a comment