Ticket #21044: openbrowser.diff
File openbrowser.diff, 1.7 KB (added by ryandesign (Ryan Carsten Schmidt), 15 years ago) |
---|
-
files/openbrowser
11 11 # e.g. a text editor. 12 12 # 13 13 # usage: openbrowser [ file | url ] [ ... ] 14 #15 # Thanks to John Gruber for coincidentally posting the code I'd been16 # seeking for reading the http helper from Internet Config.17 # http://daringfireball.net/2009/02/do_shell_script_premature_optimization18 14 19 use Mac::InternetConfig; 15 sub GetBrowser { 16 use Mac::PropertyList qw(parse_plist_file); 17 my $browser = "com.apple.safari"; 18 my $plist_file = "$ENV{HOME}/Library/Preferences/com.apple.LaunchServices.plist"; 19 $data = parse_plist_file($plist_file); 20 if ($data) { 21 for my $handler ($data->{"LSHandlers"}->value()) { 22 $handler->{"LSHandlerURLScheme"} || next; 23 "http" eq $handler->{"LSHandlerURLScheme"}->value() || next; 24 $browser = $handler->{"LSHandlerRoleAll"}->value(); 25 last; 26 } 27 } 28 return $browser; 29 } 20 30 21 $browser = +(GetICHelper "http")[1];22 @open_args = ("- a", $browser);31 my $browser = GetBrowser(); 32 @open_args = ("-b", $browser); 23 33 push @open_args, @ARGV; 24 34 25 35 exec "open", @open_args; -
Portfile
3 3 PortSystem 1.0 4 4 5 5 name openbrowser 6 version 1.0 6 version 1.0.1 7 7 categories sysutils 8 8 platforms macosx 9 9 maintainers ryandesign … … 20 20 21 21 distfiles 22 22 23 depends_run port:p5-mac- carbon23 depends_run port:p5-mac-propertylist 24 24 25 25 universal_variant no 26 26