source: trunk/launch/launch/README@ 661

Last change on this file since 661 was 661, checked in by Nicholas Riley, 11 years ago

VERSION: Updated for 1.1.1d5.

main.c: Replace use of daemon(3), which was deprecated in Mac OS X
10.5. Updated for 1.1.1d5.

README: Updated for 1.1.1d5.

Note: man page is out of date, needs updating before 1.1 is released.

Should also investigate enabling BROKEN_ARGUMENTS and either enabling
or removing BROKEN_AUTHORIZATION.

File size: 10.8 KB
RevLine 
[314]1launch 1.1.1 [unreleased]
2============
[3]3
4A command-line launcher for Mac OS X in the spirit of open(1).
5
6Written by Nicholas Riley <mailto:launchsw@sabi.net>.
7Obtain updates from <http://web.sabi.net/nriley/software/>.
8
9WHAT IS IT?
10-----------
11
12Apple provides a simple command-line launching program called 'open'
13with Mac OS X. It offers few options - launching applications by name
14or by path, launching TextEdit, or opening a number of applications,
[52]15documents, folders, or URLs. With the exception of special support for
[214]16TextEdit (open -e), 'launch' does all this and:
[3]17
18- opens URLs, directly or in your preferred helper application (-l)
19- lets you specify applications by their four-character creator
20 (e.g. 'ToyS') or Java-style bundle ID (e.g. com.apple.scripteditor),
21 both of which allow you to move or rename an application without
22 changing references to it
23- asks applications to print documents, something the OS X Finder
[214]24 didn't get until Mac OS X 10.4
[52]25- allows you to pipe output to GUI applictions
[3]26- launches applications in the background
27- launches Carbon applications in Classic
28- displays file information including type, creator, bundle ID,
[146]29 data and resource fork sizes, dates and version
[3]30- reports errors intelligibly
31- and much more!
32
33'launch' is useful by itself, but is even better when used in scripts.
34Assign a shell command to your favorite Mac OS text, graphics or
35resource editor. Go to your favorite Web site with a few keystrokes.
36
37Like 'open', 'launch' provides one half of the round-trip between
38Terminal.app and the Finder. You can drag and drop icons or proxy icons
39into Terminal.app to insert their paths into command lines. To go in the
40other direction, just type 'launch .' (or 'open .') to open a Finder window
41showing the current directory.
42
43INSTALLATION
44------------
45
46The commands below install the 'launch' tool in /usr/local/bin, which
47is in the default path. You should subsequently be able to use
48'launch' by typing its name. If you wish to install it somewhere else,
49modify the install line as appropriate.
50
[146]51% sudo /usr/bin/install -d /usr/local/bin /usr/local/man/man1
[267]52% sudo /usr/bin/install -c launch /usr/local/bin
[146]53% sudo /usr/bin/install -c launch.1 /usr/local/man/man1
[3]54% rehash
55
56Uninstallation:
57
[166]58% sudo rm -f /usr/local/bin/launch /usr/local/man/man1/launch.1
[3]59
60COMPILATION
61-----------
62
[308]63An Xcode project, 'launch.xcodeproj', is included. A precompiled
64Universal binary is also provided. 'launch' was developed and tested
[477]65under Mac OS X 10.5.2 with Xcode 3.1, and does not require any
[308]66additional software to build.
[3]67
68USAGE
69-----
70
71Just type 'launch' by itself to receive usage information.
72
73Some examples:
74
75% launch -c 'R*ch'
76[BBEdit opens]
77
78% launch -pbc 'R*ch' test.txt
79[BBEdit starts printing test.txt in the background]
80
[54]81% ls -l | launch -c CWIE -
[52]82[CodeWarrior IDE opens with an untitled document containing the file list]
[3]83
[214]84% launch -i org.mozilla.camino http://www.apple.com/
[146]85[Camino opens Apple's Web site]
[52]86
87% launch -l launchsw@sabi.net
88[Your preferred email client opens a new message to comment on launch]
89
90% launch -f /Applications/Preview.app
[308]91/Applications/Preview.app: Mac OS X application package
[3]92 type: 'APPL' creator: 'prvw'
[308]93 architecture: Intel 80x86, PowerPC
[3]94 bundle ID: com.apple.Preview
[308]95 version: 3.0.8
[3]96 kind: Application
[308]97 content type ID: com.apple.application-bundle
[146]98 contents: 1 item
[3]99[...]
100
[146]101A scripting example: a zsh function which provides an OS X wrapper
102around emacsclient and the Carbon build of GNU Emacs, using launch and
103appswitch (another one of my command-line tools).
104
105 e() {
106 ( emacsclient -n $@ >&/dev/null && \
[309]107 appswitch -a Emacs ) || \
[146]108 ( launch -ba Emacs && \
109 until { emacsclient -n $@ >&/dev/null } do sleep 1; done;
110 appswitch -a Emacs )
111 export EDITOR=emacsclient
112 }
113
[3]114FREQUENTLY ASKED QUESTIONS
115--------------------------
116
117Q. How do I discover bundle IDs for applications?
118
119A. The -f option to launch can help. Say you have OmniWeb in the
120/Applications/Internet folder, and want to find out its bundle ID.
121Type 'launch -f', and drop the OmniWeb icon on Terminal:
122
123% launch -f /Applications/Internet/OmniWeb.app
[308]124/Applications/Internet/OmniWeb.app: scriptable Mac OS X application package
[3]125 type: 'APPL' creator: 'OWEB'
[308]126 architecture: PowerPC, Intel 80x86
127 bundle ID: com.omnigroup.OmniWeb5
[3]128
129Note that bundle IDs are not case-sensitive: com.barebones.BBEdit is
130the same as com.barebones.bbedit.
131
132
[52]133Q. Why does application X open a file with a name beginning with
134'launch-stationery-'?
135
136A. Your application does not support stationery. Applications which
137support stationery respond to it by creating a new untitled document
[146]138with the contents of the stationery. Most Cocoa applications, such as
139TextEdit, do not support stationery. (Omni Group applications are a
140notable exception.) If you're looking for a text editor which
141supports stationery, try BBEdit, Tex-Edit Plus, the CodeWarrior IDE,
142or almost any other Carbon editor.
[52]143
144For the curious: launch processes input by simultaneously reading it
145and writing to a temporary stationery file. Once reading is complete,
146launch opens the stationery file with your selected application, and
147deletes the stationery after one minute (as a safeguard, it is not
148possible to accurately gauge how long it will take for the application
149to open the stationery).
150
151
[3]152Q. Why can't I use -f with -c to get info on an application with a
[52]153given creator (or -f with -i for a bundle ID)?
[3]154
155A. This feature may be added to a later version (or add it yourself!),
156but there is a workaround. Instead of:
157
158% launch -f -c 'Doug'
159launch: can't get information (-f) on item(s) using an application (-u, -c, -i, -a)
160
161use:
162
163% launch -f "`launch -nc 'Doug'`"
164/Volumes/GrayApps/Utilities/Resorcerer 2.4/Resorcerer: scriptable Mac OS X application [Carbon, prefers native OS X]
165 type: 'APPL' creator: 'Doug'
[146]166 bundle ID: com.mathemaesthetics.resorcerer
167 version: 2.4 [0x2418010 = 37847056]
[3]168 kind: Application
[146]169[...]
[3]170
171
172Q. Why doesn't launch support opening items as root?
173
174A. Apple eliminated this capability with the Mac OS X 10.1 Security
175Update. If at some point Apple restores this capability, 'launch'
176will be ready to support it.
177
178
179Q. Why do I get an error -600?
180
181A. A typical occurrence of this would be:
182
183% launch -n .
184launch: can't open items: unable to connect to system service.
185Are you logged in? (-600)
186
187In order to perform certain operations, launch needs to talk to
188various system services owned by the currently logged-on user. If you
189aren't using 'launch' from a terminal currently logged into the Mac OS
[166]190X GUI, certain operations may not work. Try opening Terminal, creating
191a new terminal window, and trying again.
[3]192
193Another possibility is to create your own interprocess messaging.
194For example, place this script in a file:
195
196#!/bin/sh
197PIPE=/tmp/.launchpipe
198[ -e $PIPE ] || mkfifo $PIPE
199while true; do
200 read opts < $PIPE
201 eval "/path/to/launch $opts" & # change this to launch's path
202done
203
204Then, define a function or alias. For zsh:
205
206rlaunch() { echo $@ > /tmp/.launchpipe }
207
208Or for tcsh:
209
210alias rlaunch 'echo \!* > /tmp/.launchpipe'
211
212Start the shell script above from the console, then you can use
213'rlaunch' in place of 'launch' logged in from anywhere else.
214
215Thanks to robert <robert@allyourbass.org> for this suggestion.
216
217COMMENTS, SUGGESTIONS, BUG REPORTS, ETC.
218----------------------------------------
219
220Please send to the author, Nicholas Riley, at <launchsw@sabi.net>.
221
222VERSION HISTORY
223---------------
224
[314]2251.1.1 - unreleased
[661]226 - update error codes and eliminate use of deprecated API for OS X
227 10.8
[477]228 - read Info.plists embedded in all Mach-O binaries (e.g. hdiutil)
[490]229 - display alias targets
[661]230 - now requires Mac OS X 10.6 or later
[309]2311.1 - 30 October 2006
[265]232 - -L: send "launch" (ascr/noop) event to app, bypasses automatic
[304]233 opening of untitled document, etc.
[310]234 - -o: pass command-line arguments (broken, r. 4474993)
[214]235 - display content type ID (UTI)
[308]236 - display architecture of Mach-O files
[214]237 - switched to new LSOpen APIs (now requires Mac OS X 10.4 or later)
[265]238 - switched to new date formatting APIs (the old ones are deprecated)
[214]239 - for compatibility with open(1), take app path as argument to -a
[304]240 - Universal Binary, compatible with Intel Macs [Peter Hosey]
[166]2411.0.1 - 3 April 2005
242 - prefer files to URLs; added -U for old behavior
243 - don't display extraneous leading './' on file paths
244 - display 'zero items', not '0 items', for consistency
245 - display versions of non-applications
246 - read Info.plists embedded in unbundled Mach-O applications
247 - non-ASCII arguments are now handled with the filesystem, rather
248 than the system encoding [Derrick Bass]
249 - explicitly use UTF-8 everywhere else to properly interpret and
250 display non-ASCII filenames and URLs
251 - reading OSTypes and 'vers' resources, and opening URLs with
252 Internet Config still uses the system encoding, converting as
253 necessary for display
254 - should be buildable on 10.2 again
[146]2551.0 - 23 October 2003
[137]256 - work around CFBundle bug to report bundle identifiers and versions
257 from resource forks of unpackaged Carbon applications and Classic
258 applications [Lloyd Dupont]
[146]259 - added descriptions for more error codes and clarified error
260 reporting
261 - output all errors to stderr
262 - provide better errors for -X option
263 - restored -m: OS X bug is fixed in Panther
264 - fixed a couple of tiny memory leaks
265 - added man page [Hisashi T Fujinaka]
266 - work around bug in LSOpenFromURLSpec opening multiple items in
267 Mac OS X 10.3
[127]2681.0b2 - 9 March 2003
269 - fixed install instructions to create /usr/local/bin if needed
270 - show bundle version with text, hex and integer representations
[52]2711.0b1 - 14 December 2002
272 - accept "slack" (default http) URLs and email addresses with -l
273 - accept input from stdin with '-'
274 - open URLs with arbitrary applications when specified without -l
275 - builds without compiler warnings
2761.0a9 - 2 April 2002
277 - license, comments changes
2781.0a8 - 29 March 2002
279 - errors with -l (from ICeCoffEE), added rlaunch script
2801.0a7 - 3 March 2002
281 - print dates, sizes, folder valence, locked status for -f
282 - don't abort on failure to obtain bundle information
2831.0a6 - 30 November 2001
284 - fixed incorrect messages, broken -u and crash on -nu
2851.0a5 - 28 November 2001
286 - print kind string for -f, still no new installer
2871.0a4 - 20 November 2001
288 - [try to] use Installer VISE instead of InstallAnywhere
2891.0a3 - 15 November 2001
290 - fixed package identification in -f, updated examples
2911.0a2 - 15 November 2001
292 - -f, removed broken -m
2931.0a1 - 14 November 2001
294 - renamed from "FindApp", launch by default, -u
2951.0d5 - 7 November 2001
296 - option -s for launching as root [nonfunctional]
2971.0d4 - 6 November 2001
298 - URL launching and Internet Config support
2991.0d3 - 4 November 2001
300 - more robust, support for docs without app
3011.0d2 - 4 November 2001
302 - options -opsbmhCX, -cin, documents
3031.0d1 - 26 August 2001
304 - returns path of application identified by creator
Note: See TracBrowser for help on using the repository browser.