Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / September 2006



Tip: Looking for answers? Try searching our database.

logout hooks

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Donald Hall - 26 Sep 2006 07:01 GMT
I am trying to implement a logout hook with one of my programs and not
having any luck getting it to work. I thought I would give Mike
Bombich's LoginWindow Manager program a try to see what it did to the
loginwindow plist. Unfortunately, I can't get that to work either.

Here is my test script:

#!/bin/bash
echo test > /tmp/logouttest.log

I can run this script just fine from a Terminal window - the test file
appears as expected. However when I try to make it a logout hook in
LoginWindow Manager and click on the test button, I get the following
message:

AppleScript Error
The variable msg is not defined. (-2753)

As my test script has nothing to do with AppleScript, I assume this
means some kind of problem with LoginWindow Manager, which appears to be
an AppleScript Studio application.

Also, if I click on 'Apply', I am asked to enter an admin password. I do
so. However, neither version of com.apple.loginwindow.plist (my
Preferences or /Library/Preferences) is changed.

Test system is iBook G3 running OS X 10.4.5. LoginWindow Manager is
2.0.2.

By the way, does anyone know why admin privileges are needed to create a
user specific logout hook? I had no trouble adding 'LogoutHook' to  
~/Library/Preferences/com.apple.loginwindow.plist. (But, it didn't seem
to cause my script to run when I logged out...)

Thanks for any help anyone can give me.

Don Hall

Signature

Donald S. Hall, Ph.D.
Apps & More Software Design, Inc.
http://www.appsandmore.com
don at appsandmore dot com
"Schedule your scripts with Script Timer"

Reinder Verlinde - 26 Sep 2006 12:15 GMT
> By the way, does anyone know why admin privileges are needed to create a
> user specific logout hook? I had no trouble adding 'LogoutHook' to  
> ~/Library/Preferences/com.apple.loginwindow.plist. (But, it didn't seem
> to cause my script to run when I logged out...)

Login and logout hooks are intended to be used by a system administrator
to tailor a system.

Given that

a) these run with root privileges (see
  <http://docs.info.apple.com/article.html?artnum=301446>: "Unlike
  Startup Items that open when a user logs in, a login hook is a script
  that executes as root."

b) (on my system) ~/Library/Preferences/com.apple.loginwindow.plist is
  writable by me

c) I can not find documentation ever mentioning user-specific login hooks

I strongly suspect that it is not possible to specify login or logout
hooks in ~/Library/Preferences/com.apple.loginwindow.plist.

So, if you want to run code with user privileges at login, use a startup
item.

AFAIK, there is no functionality for running things at logout with user
privileges yet. The easy workaround would be to run a background-only
daemon from a startup item, and to have this daemon call the logout
script when the application is asked to exit. Warning: depending on the
way you do this, it might interfere with the logout process (for
example, the Finder might put up an alert "shutdown item has cancelled
the logout process")

Reinder
Donald Hall - 27 Sep 2006 05:45 GMT
> > By the way, does anyone know why admin privileges are needed to create a
> > user specific logout hook? I had no trouble adding 'LogoutHook' to  
[quoted text clipped - 31 lines]
>
> Reinder

Reinder,

Thanks for taking the time to reply, and for the document reference. I
think I have a better understanding of why root privileges are needed.
There are a number of references to running logout hooks on the web -
for example, a way to mute the startup chime. They all use "sudo
defaults write com.apple.loginwindow LogoutHook /path/to/script". For
some reason this fails to work for me. (My test script works fine
otherwise - I don't think it is the problem.)

I already tried your suggestion of running a background program that
would run a script when it was sent a quit message. Unfortunately, while
the system sends a quit message to all running programs, it only waits
for a reply from foreground apps - background apps are immediately
killed. I tried having my background app start up a foreground app that
would simply run the script, but that too is cut off at the knees - I
guess because it is a child of the background app.

Regards,

Don

Signature

Donald S. Hall, Ph.D.
Apps & More Software Design, Inc.
http://www.appsandmore.com
don at appsandmore dot com
"Schedule your scripts with Script Timer"

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.