Bluetooth Proximity User Switching

Okay, off of a few Digg posts I read and found a program to detect the proximity of my cellulars bluetooth. This would be ideal for me as in my office we are required to bring our workstations down to the Login Window if we leave our desks, and accounts are password protected. Following posts and such I found a way to write a script to take the Apple to the login screen, but non that really illustrate how to log the user back into their session.

Now first off I am aware that this can be less secure, but I really don’t care about that, most of the folks in the office are like me and really only work with security on an http level, not hacking coworkers computers.

Can anyone point me in the right direction on how to script this? And yes, I did search the forum to make sure I wasn’t just asking something that has been answered over and over :slight_smile:

Thanks in advance everyone!

Okay, here’s what I have so far:

On exit: (yes, everyone knows about this one online)

do shell script "/System/Library/CoreServices/Menu\\ Extras/ -suspend"

On return: (password is going to be in *'s)

set uid to do shell script "id  -u myuser"
set passwd to do shell script "passwd **********"

do shell script "/System/Library/CoreServices/Menu\\ Extras/ -switchToUserID " & uid & passwd

Now, this works in a sense as when I have to manually log in, the prompt is there inside the open session, now how do I get it to recognize from the login panel and not within the User itself?

Again, thanks for any help or guidance tossed my way.

Model: Powermac G4 Quicksilver 2002
AppleScript: AppleScript 1.10.7
Operating System: Mac OS X (10.4)

A Bluetooth keyboard can do it, so there must be a way. If so, I’ve never discovered it and I have a GSM/Bluetooth phone.

In further reading, does anyone think that my path on returning to the computer should be changed from:

/System/Library/CoreServices/Menu\ Extras/ -switchToUserID
/System/Library/CoreServices/ -etcetera?

This works here:
You could set 4 osascript triggers

do shell script "osascript -e 'do shell script \"sleep " & 1 & "\" ' -e 'tell application \"System Events\" to tell  process \"CoreServices\" to  keystroke \"Password\"  '  -e 'do shell script \"sleep " & 1 & "\"'  -e  'tell application \"System Events\" to tell  process \"CoreServices\" to  keystroke return'> /dev/null 2>&1 & "

just before

do shell script "/System/Library/CoreServices/Menu\\ Extras/ -switchToUserID " & uid & passwd

in order to type the passw and hit return in the login dialog (owned by CoreServices).

Excellent scripting Eelco Houwink, but alas it does not run in the system loginwindow, testing the applescript I can see it work flat out, now if I can only figure out how to add the proximity app as a system item and not a user based app, then I’d be golden. Through much more searching I am unable to find a solution, maybe my quest is just out of reach.

Any suggestions?

So if I understand you well, this only works after returning to a suspended session, but not as a pure login item before login has completed.
Interesting issue - you want to trigger a system process before that.
But then the question is, how do you get your proximity app loaded a that time…? (which one is it, can’t be Salling Clicker then…?)

It vaguely reminds me to a discussion on sending iSight pictures across the internet at the occasion of false login attempts,
it required tweaking into launchd - but I do not know whether that was successfull. Look here:

My guess is that it’s Home Zone, excellent program. Still in free beta

And Home Zone isn’t running when the user is logged out. It can, however, require a password on the screensaver when the phone is out of range, and restore it to no password when the phone is present, so the OP could have it activate his screensaver and turn on a password for it when he left the zone, and then turn off the password requirement and disable the screen saver when he returned. He’s not logging out, but he is locking down his machine. If IT checks whether his machine is online, he can also change networks, effectively taking his machine off line.

Home Zone’s options on entering and leaving the zone are:

Change Network
Disable Screen Saver Password
Enable Screen Saver Password
Lock Keychains
Mute System Volume
Open File – can be an
Pause iTunes
set Default Printer
set System Volume
Start Screen Saver
Stop Screen Saver
Synchronize iSync – what I actually use it for
Unmute System Volume

In that situation, my re-activation script SHOULD work.
But I am afraid that’s no the case the original writer refers to.
Callseven, can you come in and describe what your situation actually is…?

Yes, I had checked out Homezone prior to this, as well as Proximity, both have the ability to do a Screensaver/Password on/off switch. In my other script I have one that upon leaving range it takes you to the login panel, I need to figure out how to have Proximity run as a system program, but I cannot figure that out. I may just have to type in my password, if that’s the way it is then that’s the way it is I suppose.

But for an alternate wording, I am looking for the program to detect proximity of the bluetooth phone and log back into my running session, but it also has to toss in the password variable. Thanks to Eelco Houwink’s scripting that code works perfect, but now it’s about setting up a program to run under the system user and not just my user.

I appreciate you guys putting your heads together on this, I am behind the curve on Applescripting in a huge way.