Re: [gtk+osx] Working .app bundles
Status: Beta
Brought to you by:
jralls
From: Chris S. <sa...@ma...> - 2004-01-06 00:46:31
|
Bob -- It would probably be better to craft a /bin/sh script rather than rely on perl or python being installed. I'm not much of a scripter, but you could try this out to see what happens: #!/bin/sh ExecutableName=$1; LaunchType=$2; Psn=$3; Executable=$ExecutableName-executable; #echo ${ExecutableName} #echo ${Executable} #echo ${LaunchType} #echo ${Psn} if [ "${LaunchType}" = "-psn" ]; then ./${Executable} else echo "Launching via command line" ./${Executable} fi However, I think the best way to fix this is to fix apps which expect command line arguments to explicitly check for them and not barf when they get passed an option like -psn. -- Chris On Jan 5, 2004, at 4:13 PM, Bob Ippolito wrote: > On Jan 5, 2004, at 5:50 PM, John-Michael Mulesa wrote: > >> Bob Ippolito wrote: >>> On Jan 5, 2004, at 4:46 PM, Bob Ippolito wrote: >>>> >>>> On Jan 5, 2004, at 4:20 PM, John-Michael Mulesa wrote: >>>> >>>>> Does anyone here know how to make a gtk-osx .app bundle program >>>>> double clickable? Right now you still have to run it from >>>>> terminal, because if you double click it, it immediately quits and >>>>> outputs this to the console (GIMP - OSX in this case): >>>> >>>> >>>> Yeah, this is a quick hack, but change main to something like this: >>>> >>>> int main(int argc, char **argv) { >>>> if (argc == 2 && strncmp(argv[1], "-psn", 4) == 0) argc = 1; >>>> /* rest of code */ >>>> } >>>> >>>> argv is used for something else when launching .app bundles >>>> (passing in a process serial number). Opening files or printing is >>>> actually done by an 'odoc' event post-launch, not with argv. >>>> >>>> Alternatively, you can change the Info.plist to use a different >>>> executable (can even be a python script, so long as its +x and you >>>> don't need 10.1 compat) whose sole purpose is to swallow the >>>> "extraneous" arguments and then execve the actual process. >>> And here's an example.. to get the demo "gimp 1.2" app bundle to run >>> by double clicking: >>> cd /Applications/gimp-1.2.app/Contents/MacOS >>> mv gimp-1.2 gimp-1.2-executable >>> create a gimp-1.2 file that looks like this: >>> #!/usr/bin/python >>> import sys, os >>> if len(sys.argv) == 2 and sys.argv[1].startswith('-psn'): >>> sys.argv = sys.argv[1:] >>> os.execve(os.path.join(os.path.dirname(sys.argv[0]), >>> os.path.basename(sys.argv[0])+'-executable'), sys.argv[:1], >>> os.environ) >>> chmod +x gimp-1.2 >> I made the file, but it doesn't want to run (did do chmod +x): >> >> /Users/jm/Desktop/gimp-1.2.app/Contents/MacOS/gimp-1.2: Command not >> found. >> >> When I try to run it. > > In theory, I guess that can happen if you don't have Python. Maybe > you don't have the BSD subsystem installed? Otherwise you should have > it, because it's been a standard part of the BSD subsystem since OS X > 10.2. > > -bob ------------------ 6 Infinite Loop M/S 306-2MS Cupertino CA 95014 phone: (408) 974-4033 fax: (408) 862-7577 email: sa...@ap... |