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


Click here to return to the 'Modify script to quit Classic' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Modify script to quit Classic
Authored by: ashill on Dec 08, '01 02:34:58PM
If you add the line
tell application "Classic Support" to quit
inside the if statement, this script will cleanly quit Classic (i.e. it will do a shutdown, allowing you to save changes in running Classic applications). Finally, a way to quit Classic without going to System Prefs! -Alex Hill

[ Reply to This | # ]
Modify script to quit Classic
Authored by: rusto on Dec 08, '01 05:07:11PM
Why not let the user decide whether to quit Classic upon discovering that it is running:
tell application "Finder"
if (name of (every application process)) contains "Classic Support" then
activate
say "Classic is running."
display dialog "Want to quit Classic?" buttons {"No", "Yes"} default button "No"
set the user_choice to the button returned of the result
if the user_choice is "Yes" then
tell application "Classic Support" to quit
end if
else
say "Classic is not running."
end if
end tell
Unfortunately, the way AppleScript seems to work in OS X, you have to bring the finder to the front for that dialog box to appear.

[ Reply to This | # ]
Nice!
Authored by: RichB on Dec 08, '01 06:09:51PM

Better than "The Classic Environment" freeware script.

Use that 9 icon too for a nice effect!



[ Reply to This | # ]
Modify script to quit Classic
Authored by: babbage on Dec 08, '01 07:53:50PM
Better still, why not let the user decide either way? I don't really know Applescript very well, but it looks like you can do something like this:
tell application "Finder"
if (name of (every application process)) contains "Classic Support" then
activate
say "Classic is running."
display dialog "Want to quit Classic?" buttons {"No", "Yes"} default button "No"
set the user_choice to the button returned of the result
if the user_choice is "Yes" then
tell application "Classic Support" to quit
end if
else
activate
say "Classic is not running."
display dialog "Want to launch Classic?" buttons {"No", "Yes"} default button "No"
set the user_choice to the button returned of the result
if the user_choice is "Yes" then
tell application "Classic Support" to launch
end if
end if
end tell
Alternatively, you should be able to poll classic through the terminal:
[localhost Sat 7:22:21pm ~]% ps aux | grep Classic
chris 405 0.0 0.1 1112 100 std U+ 0:00.01 grep Classic
[localhost Sat 7:43:07pm ~]% # launch classic from system preferences
[localhost Sat 7:47:27pm ~]% ps ax | grep Classic
406 ?? S 0:32.51 /System/Library/CoreServices/Classic Startup.app/Contents/MacOS/Classic Startup -psn_0_1441793
407 ?? R 0:59.28 /System/Library/CoreServices/Classic Startup.app/Contents/Resources/TruBlueEnvironment
412 std R+ 0:00.01 grep Classic
[localhost Sat 7:47:56pm ~]%
i.e. bring up a list of all running processes & filter it down to just ones realted to Classic. If you have anything running, then Classic must be running. If the only hit you get is the grep command (which doesn't always show up) then Classic isn't running. I haven't tried to wrap this up in a pretty script that will bring Classic up or down, partly because I'm lazy (I just want to know if it might need launching or halting, and don't mind going elsewhere to do it if so, in this case), and partly because I'm not sure how to do it from the shell anyway. I think you can just open a classic application & trick it into opening, and it might be kosher to "sudo kill -9" any Classic processes you find (???), but I'm not sure how good either of these solutions are, and since the point here is just to ask, not to do anything about the answer, then it's sufficient for me.

[ Reply to This | # ]
Modify script to quit Classic
Authored by: rusto on Dec 08, '01 10:01:14PM
Gah, you beat me to it! I blame my wife, "Hurry up, dinner's ready!" Geez. I've also modified the script to offer the other option, grab it ready to go, here: ClassicCheck

[ Reply to This | # ]
new non auditable spin on this latest variant
Authored by: meancode on Dec 08, '01 10:26:16PM
thanks a lot. i put the script in the Dock and also in the Script Menu. it works 99% of the time. but occasionaly i have to force quit it. then re-run the script again and it works every time. also this latest version of the script will bring the finder to the foreground so you do not have to click the finder. dont know why as there is no difference to the tell command. i edited it a tad, took out the "say" here is my edited version.
tell application "Finder"
if (name of (every application process)) contains "Classic Support" then
activate
display dialog "Classic is running, want to quit it?" buttons {"No", "Yes"} default button "No"
set the user_choice to the button returned of the result
if the user_choice is "Yes" then
tell application "Classic Support" to quit
end if
else
activate
display dialog "Classic is not running want to launch it?" buttons {"No", "Yes"} default button "No"
set the user_choice to the button returned of the result
if the user_choice is "Yes" then
tell application "Classic Support" to launch
end if
end if
end tell
it works great! thanks to all that have contributed to making this script even better and more functional than the one rob originally posted. Ken Edwards ken@meancode.com

[ Reply to This | # ]
just added restart
Authored by: stift on Dec 09, '01 07:35:02AM
just modified the script with a restart option, if someone needs that just grab it here

[ Reply to This | # ]
just added restart
Authored by: RichB on Dec 09, '01 05:32:08PM

Saved As Run Only means I can't edit your choices. An application with out startup screen is enough.



[ Reply to This | # ]
just added restart
Authored by: ben on Mar 10, '02 11:13:56PM

Great!Thanks Ben



[ Reply to This | # ]