html and postscript viewer

Kevin Walzer kw at codebykevin.com
Wed Mar 30 18:36:12 PDT 2016


On 3/30/16 9:28 PM, Ryan Schmidt wrote:
> /usr/bin/open is not necessarily suitable. For example, I have configure my system so that if I `open` a .html file, it opens into my text editor, because I frequently edit html files. However, if another program is trying to open a web page, then I want that web page to open in my web browser, not my text editor.
>

You are technically correct, but I suspect your use case is going to be 
applicable only for a small group of users who are also developers.

/usr/bin/open is the command-line interface to the LaunchServices API, 
which is supposed to handle all this. I am not aware of any clean way to 
query Safari's preferences to determine the default browser without 
groveling through plist files, or perhaps AppleScript.

(Looking on the web, I see your openbrowser script does exactly 
that--grinds through plist files via Perl--but that introduces an 
additional dependency. I'd suggest that using a system-bundled tool is 
almost always better. It's certainly simpler.)

--Kevin

-- 
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com



More information about the macports-dev mailing list