Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
H

HaraldBT

Guest
Original poster
Hi,

I want to make an applescript that checks a list over networks, if none of those networks are nearby it will turn on password protection. I already have what the code for turning on password protection, but how can I check the networks?
 

GGJstudios

macrumors Westmere
May 16, 2008
44,545
943
Hi,

I want to make an applescript that checks a list over networks, if none of those networks are nearby it will turn on password protection. I already have what the code for turning on password protection, but how can I check the networks?
What do you mean "it will turn on password protection"? If you're referring to your WiFi network, you should always have it protected with a secure WPA2 password, regardless of what other networks may be nearby.
 
H

HaraldBT

Guest
Original poster
It will turn on the password protection on my mac. That way, the password will turn on when I leave my home.
 
H

HaraldBT

Guest
Original poster
I mean that you need the password to wake up the mac.
 

GGJstudios

macrumors Westmere
May 16, 2008
44,545
943
I mean that you need the password to wake up the mac.
You can always have your Mac set to require a password to wake from sleep or screensaver. That has nothing to do with the presence of nearby WiFi networks.
 
H

HaraldBT

Guest
Original poster
I should probably describe this a little better: I want an applescript that checks what networks are nearby. If none of the the networks that are around at my home is nearby, it turns on password protection. I don't want to have password protection on my mac at home, but I want it to turn on automatically when I leave my home and open my mac. That way I keep the people I'm my class from playing Angry Birds on it.
 

GGJstudios

macrumors Westmere
May 16, 2008
44,545
943
I should probably describe this a little better: I want an applescript that checks what networks are nearby. If none of the the networks that are around at my home is nearby, it turns on password protection. I don't want to have password protection on my mac at home, but I want it to turn on automatically when I leave my home and open my mac. That way I keep the people I'm my class from playing Angry Birds on it.
Again, the presence of other networks has no effect on whether you use a password on waking from sleep or screensaver. The two are unrelated. Just go to System Preferences > Security and check or uncheck "Require password to wake this computer from sleep or screen saver", when you want to turn it on or off. What networks are present in the area has nothing to do with whether or not you use that feature. It's not related to networks at all. The networks that are near your home could be online or offline at any point, even if you're at home, which would have no effect on your system either way.
 
H

HaraldBT

Guest
Original poster
I know they're not related. I want an applescript to activate password protection if none of the usual networks are around.
 

GGJstudios

macrumors Westmere
May 16, 2008
44,545
943
I know they're not related. I want an applescript to activate password protection if none of the usual networks are around.
That still doesn't make sense. That's like automatically turning on the air conditioning in your car if someone changes the TV to channel 4. One has nothing to do with the other. The presence or absence of networks is subject to change, even if you're at home. If none of the networks are available at any given point in time, that doesn't necessarily mean you're not at home. Also, having a script (even if you could create one) wouldn't activate until the computer was awake. So if you put your Mac to sleep at home, then took it to school and woke it up, it would wake without the password, because it would need to first wake up before it ran a script or could detect the presence of networks. Likewise, if you had the password enabled at school, put the computer to sleep, then woke it up at home, it would require the password, because it would first need to wake up to run a script or check the presence of networks. The whole approach is poorly conceived.
 
H

HaraldBT

Guest
Original poster
That is the point. When I come home, I would have to wake it up anyway before disabling password protection, and vice versa. And I know that the networks may change. I am not asking if makes sense or not, I'm asking if there is a way to do it.
 

GGJstudios

macrumors Westmere
May 16, 2008
44,545
943
That is the point. When I come home, I would have to wake it up anyway before disabling password protection, and vice versa. And I know that the networks may change. I am not asking if makes sense or not, I'm asking if there is a way to do it.
No, there's not. As already stated, no script can run and no network can be detected in sleep mode.
 
H

HaraldBT

Guest
Original poster
Not in sleep mode, WHEN IT WAKES. I can easily use Sleepwatcher to run an applescript when it wakes.
 

LaWally

macrumors 6502a
Feb 24, 2012
530
1
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s

will list all available networks. I know it's possible to run the above command within a bash script and capture the output, but don't know about Apple Script. I'm thinking not.

It seems to me that what you are proposing though is a solution in search of a problem. Why not just leave password on wake active all the time. Is that so inconvenient?

I like to keep things simple.
 
H

HaraldBT

Guest
Original poster
Thank you, I might be able to somehow use this!

It's not exactly inconvenient, but it's a little annoying to always have to use the password when I'm at home, and I always forget to turn it off.
 

LaWally

macrumors 6502a
Feb 24, 2012
530
1
Thank you, I might be able to somehow use this!

It's not exactly inconvenient, but it's a little annoying to always have to use the password when I'm at home, and I always forget to turn it off.

Don't know if you keep regular hours, but you could set up your Mac to shutdown at a scheduled time every day.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.