Oct 18, '04 10:48:00AM • Contributed by: brianboonstra
Begin by installing WinSwitch (the Win comes not from Microsoft but from the first name -- Wincent -- of the developer). This is a freeware (but do consider donating!) MenuExtra that replaces Apple's own Fast User Switching menu. The nice thing about WinSwitch is (besides being, IMO, well-written) that it listens for notifications of NSWorkspaceSessionDidResignActiveNotification and NSWorkspaceSessionDidBecomeActiveNotification. WinSwitch will automatically run items found in ~/Library -> Application Support -> WinSwitch -> Switch-In Items and ~/Library -> Application Support -> WinSwitch -> Switch-Out Items by using the equivalent of double-clicking them in the Finder ([[NSWorkspace sharedWorkspace] openFile:itemPath], if you care to know). We use this to automatically quit HP Communications for the user switching out, and start it for the user switching in.
First, create ~/Library -> Application Support -> WinSwitch -> Switch-In Items -> StartHP.command, containing the following script:
#!/bin/sh
#ac
# wakeup: start HP Commmunications process
#
open /Library/Printers/hp/HP Communications.app
and then do a chmod 755 Library/Application Support/WinSwitch/Switch-In Items/StartHP.command to make it executable. Now create ~/Library -> Application Support -> WinSwitch -> Switch-Out Items -> Kill_HPCommunications.command, containing:
#!/bin/sh
#
# kill HP Communications process
#
kill -HUP `ps axwww | egrep -i
"/Library/Printers/hp/HP Communications.app" | egrep -iv
"egrep -i" | awk '{print $1}'`
killall pipedaemon
and again change the permissions by typing chmod 755 ~/Library/Application Support/WinSwitch/Switch-Out Items/Kill_HPCommunications.command
[/code]
Now log in or switch to all the other users, and create the same scripts. If you want to keep the scripts in a central location and symlink to them, that should work, but you must ensure that the metadata causes the commands to run (rather than, say, open in an editor) when you double-click them. While you are switched in as the other users, take a minute to run /Users -> Shared -> Activate WinSwitch.command, to get WinSwitch working for them as well.
I am successfully using this with an OfficeJet 4215, but I imagine it works with the entire 4200 series and probably all HP all-in-ones. I have three caveats:
- This tends to leave Terminal windows around with exit'ed process notifications in them. You can fix that with Window Settings (Shell) in Terminal by telling it to close windows on exit'ed processes, but it's easy to "Use As Default" and end up running the script every time you open a Terminal window (fixable by editing Terminal's preferences plist)!
- It is important to activate WinSwitch and create the scripts for every user involved in switching.
- I am not sure how this interacts with sleep problems, as I have not encountered any.
