Go Back   The macosxhints Forums > OS X Help Requests > System



Reply
 
Thread Tools Rate Thread Display Modes
Old 02-06-2003, 12:34 PM   #21
chabig
Hall of Famer
 
Join Date: Jan 2002
Posts: 3,016
When you log out or shutdown, the system tells each running application to quit, so you could just add an Applescript to your login items that does nothing. But when told to quit, ejects all disks.

Chris
chabig is offline   Reply With Quote
Old 02-06-2003, 12:42 PM   #22
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
ha! chris, that is a real clever idea. must refrain from doing too much at that point, perhaps, since shutdown is imminent and services are going bye-bye? hmm...
mervTormel is offline   Reply With Quote
Old 02-06-2003, 01:13 PM   #23
chabig
Hall of Famer
 
Join Date: Jan 2002
Posts: 3,016
OK. I searched the Developer docs and figured out how to run a script at logout. If you have installed the Developer tools, the instructions will open if you click this link: file:///Developer/Documentation/Esse...rocedures.html

It works like this--You have a file at /etc/ttys which contains among other things, this line:

Code:
console "/System/Library/CoreServices/
loginwindow.app/Contents/MacOS/loginwindow" vt100 
on secure window=/System/Library/CoreServices/WindowServer 
onoption="/usr/libexec/
getty std.9600"
BTW: This is really one long line. To make it wrap properly in Safari, I broke the line into several lines. Just remember that it's really one line.

This line tells the init program to launch loginwindow on the console terminal and to use WindowServer (which is a symbolic link to the Window Manager process) as the windowing-system process. Into this line, you can insert additional parameters for loginwindow to process.

Two useful parameters are -LoginHook and -LogoutHook. These particularly are permit custom administrative, accounting, or security programs to run as part of the login and logout procedures.

All you have to do is insert the parameter and the full path to the script you want to run, like this:

Code:
console "/System/Library/CoreServices/loginwindow.app/Contents/MacOS/
loginwindow -LoginHook /Users/Username/Scripts/ejectDisksOnLogout" 
vt100 on secure window=/System/Library/CoreServices/WindowServer 
onoption="/usr/libexec/getty std.9600"
Where you have created a script called "ejectDisksOnLogout" and placed it in a folder at ~/Scripts/

I assume the script probably cannot be an Applescript, but must be something that you could run from the Terminal.

Chris

Last edited by chabig; 02-06-2003 at 01:20 PM.
chabig is offline   Reply With Quote
Old 02-06-2003, 04:36 PM   #24
mclbruce
Hall of Famer
 
Join Date: Mar 2002
Posts: 3,878
Quote:
Originally posted by chabig
When you log out or shutdown, the system tells each running application to quit, so you could just add an Applescript to your login items that does nothing. But when told to quit, ejects all disks.

Chris

I think you are on to something there. Your code would then look something like this:

on quit
tell application "Finder"
eject the disks
end tell
end quit

I think this would work well. As far as Merv's objections go, I think logging out is pretty polite to running apps, giving them time to save things or do whatever they need to do. I guess you'd have to try it and see what happens.

The next enhancement I can think of is to make it faceless so it doesn't show up in the dock.
mclbruce is offline   Reply With Quote
Old 02-06-2003, 05:16 PM   #25
chabig
Hall of Famer
 
Join Date: Jan 2002
Posts: 3,016
Quote:
on quit
tell application "Finder"
eject the disks
end tell
end quit

Exactly!

Now about hiding the dock icon...I saw this here at MacOSXHints:

http://www.macosxhints.com/article.p...10701191518268

Chris

Last edited by chabig; 02-06-2003 at 05:31 PM.
chabig is offline   Reply With Quote
Old 02-06-2003, 11:42 PM   #26
V-tach
Prospect
 
Join Date: Jun 2002
Posts: 20
To me it would seem more elegant to use the -Logout Hook mentioned above. Could I get a shell script to run this Applescript on Shutdown, rather than have it running all the time?
V-tach is offline   Reply With Quote
Old 02-14-2003, 11:34 AM   #27
sapporo
Triple-A Player
 
Join Date: Jan 2002
Location: Cologne, Germany
Posts: 99
How about

osascript -e 'tell application "Finder" to eject the disks'

HTH,
-sapporo.
sapporo is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 05:36 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.