Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Create a silent-launch Classic script Classic
This came out of personal research on the best way to "renice" apps using AppleScript, and was inspired by the posting on increasing Quake3 performance with a script. I came up with a good AppleScript to do that as well, but more on that later...

Following the example of the Quake3 script, I set it up to cd to:

/System/Library/CoreServices/Classic Startup.app/Contents/Resources/

and had it launch "TruBlueEnvironment". The cool thing about doing it this way is that it launches quietly in the background, with no progress bar or bouncing icon. This seems to make launching Classic faster.

I also wanted to set up the script to "renice" Classic to speed it up (I use it mostly just for "Baldur's Gate" ;). I at first tried to only use the new "do shell script" feature of AppleScript, but ran into a problem where it would hang the script until after Classic/TruBlue quit, even when I sent it to the background with '&'. After much experimentation and tweaking, I found the solution.

Read the rest of the article for the script (as well as a generic app launcher and renicer script)

Silent launch and renice Classic script:
property appPath : "/System/Library/CoreServices/Classic Startup.app/Contents/Resources/"
property appName : "TruBlueEnvironment"

tell application "Terminal"
do script with command "cd '" & appPath & "';./" & appName & "&;exit"
delay 6
quit
end tell

delay 1

do shell script "sudo renice -12 -p `ps -ax | awk '{ if¬
( /" & appName & "/ && $0 !~ /awk/ ) { print $1;exit } }'`"
[Depending on the performance of your Mac, you may need to modify the delays]

That final line also shows the fruits of my experiments at finding the best way to guarantee that you're getting the process-id you want from "ps" (and until OS X comes with "pidof", it'll have to do ;).

For other applications, I prefer to use a different script that I also came up with. It's simpler and doesn't require the launching of Terminal. Here's what I use for Quake:
property appName : "Quake3"

tell application appName
run
end tell

delay 1

do shell script "sudo renice -15 -p `ps -ax | awk '{ if¬
( /" & appName & "/ && $0 !~ /awk/ ) { print $1 } }'`"
I've found the best way to launch these is to use Apple's Script Menu. Not only is it a very convenient place to keep and launch such scripts, but you don't have to worry about keeping a seperate run-only version.
    •    
  • Currently 3.00 / 5
  You rated: 4 / 5 (4 votes cast)
 
[8,822 views]  

Create a silent-launch Classic script | 11 comments | Create New Account
Click here to return to the 'Create a silent-launch Classic script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
dosn't work
Authored by: macubergeek on Feb 05, '02 08:33:27PM

Tried the script and it dies at the sudo renice line. If you are logged in as administrator, you need to be root to do renice.
Additionally the pathname has to have a set of quotes around "Classic startup.app"
I've just written a shell script, saved it as classic.command and put this in it:
/System/Library/CoreServices/"Classic Startup.app"/Contents/Resources/TruBlueEnvironment &

When terminal opens and finishes I then quit terminal with a command q
It lauches classic super fast and I can use it from the script menu



[ Reply to This | # ]
Re: doesn't work
Authored by: jiclark on Feb 05, '02 11:02:23PM

Macubergeek,

Could you give me (us) a more specific explanation of what you did to make this work another way? I have the same problem with the script "dying" at the renice stage. I'd love to find a way to make this work though, it seems like it gets Classic going in no time!!!

Thanks,
John



[ Reply to This | # ]
Make it Executable
Authored by: jiclark on Feb 07, '02 02:53:49AM

Okay, so WHAT are we making Executable?? You "UNIX geeks" seem to assume we non-geeks can just learn a new language by osmosis! Macubergeek wrote:

"I've just written a shell script, saved it as classic.command and put this in it:
/System/Library/CoreServices/"Classic Startup.app"/Contents/Resources/TruBlueEnvironment &

When terminal opens and finishes I then quit terminal with a command q
It launches classic super fast and I can use it from the script menu..."

Well, that doesn't tell ME very much I can work with. WHAT shell script? "Saved it as classic.command..." in what app??? WHERE do you put that file path line that ends in "&"; and why do you do this AFTER saving "it" as classic.command? Does "I can use it from the script menu..." mean it's an AppleScript after all?

Forgive me for being dense, but I'm lost... Can anyone make it a little less cryptic for us lame "non-UNIX geeks"??? ;-}

Many thanks,
John



[ Reply to This | # ]
Make it Executable
Authored by: jiclark on Feb 07, '02 12:14:03PM

After re-reading my post (above) this morning, I want to apologize for the nasty tone. It was not intended. It was late when I wrote that, and I sincerely intended it to have a light-hearted, teasing tone. Instead, it reads very cranky, doesn't it? Again, I apologize...

I would still love it if someone could give me a clearer explanation/description of the shell process mentioned above.

You can flog me now... ;-}



[ Reply to This | # ]
Take of the Renice it works great
Authored by: specbebop on Feb 05, '02 11:47:43PM

It failed for me at renice also. But, once I took that off, it worked great.

I was hoping that the status bar would show up in the 'Classic?' dockling but it doesn't. That's ok, Classic starts quickly and Classic? does recognize it once it's started so, that's all that matters.

Good tip. I hated the Classic start up screen.



[ Reply to This | # ]
Making renice work for all admins
Authored by: Algorythmn on Feb 11, '02 02:35:58PM
Man, I knew there was something I forgot to put in there. :) I used info from this tip to make renice available for all admins: Using renice to speed up VPC5.0 The only bad thing about the tip is that you have to use "vi", which is possibly the most cryptic editor to come out of *NIX. ;) I suggest doing a quick "man vi" to get the basic command-keys down before doing "sudo visudo".

[ Reply to This | # ]
Making it work correctly
Authored by: Algorythmn on Feb 11, '02 03:09:09PM

I added a comment to myself that shows how to get renice working for all admins w/o root's password. Also, my script works fine without quotes around "Classic Startup.app", because I have the following in the cd line:

cd '" & appPath & "'

So you wind up with:

cd '/System/Library/CoreServices/Classic Startup.app/Contents/Resources/'

Try it out in Terminal, you'll see it works. :)



[ Reply to This | # ]
Re: Making it work correctly
Authored by: jiclark on Feb 12, '02 07:30:13PM

Could you please make a more explicit set of directions for making this work? I've tried and tried, and no luck. I had a simple AppleScript working at first, but now it doesn't any more. I tried the method of using "chmod +x [filename]" that is recommended above, but that does nothing. I'm sorry to be so dense, but there has to be a way to make a very clear set of instructions for accomplishing this tip, doesn't there?

Thanks, John



[ Reply to This | # ]
Making it work correctly, part deux
Authored by: Algorythmn on Feb 18, '02 05:59:49PM
Ok, the main thing required to make the AppleScripts work as-is is to have AppleScript 1.8+, which adds the "do shell script" command. 1.8.1 comes w/OS X 10.1.2 and 1.8 w/the December 2001 Developer Tools Update.

The other thing I'm taking advantage of is removing the need to enter a password when using 'renice', which I found info for in another tip. Unfortunately, you have to use the rather unfriendly 'vi' editor for this part. If you haven't used 'vi' before, I suggest opening a Terminal window and typing "man vi" to get the command-keys down. Or you can view this webpage:

man: vi

Here's what to do in Terminal ( [...] = vi command-keys to enter ):

1) type:
sudo visudo
2) enter your password when prompted

3) move to the last line [j or down-arrow] and add this line [o]:
%admin ALL=NOPASSWD: /usr/bin/renice
4) hit escape to leave input-mode and save the file [:w]

Once this is done, admins can use "sudo renice" without having to enter a password.

If you're still having problems, you're welcome to email me and let me know what it's complaining about.




[ Reply to This | # ]
Silent Classic Startup- Startupitem
Authored by: plockhart on Mar 05, '02 11:18:20AM

Has anyone figured out the complexities of getting this to run in the users StartupItems?
Or, maybe getting it started in the loginwindow facility without the screen and progress bar eating up all that precious time to get it running?
My head is sore from banging it on this to no avail...



[ Reply to This | # ]