The Future of Deliveries Deliveries began as a hobby—it was first released as a Dashboard widget named “Apple…
Force Snow Leopard to reconnect to your wireless network
I recently bought a Mac mini to set up as a file server at home, and I’ve run into this fun problem in Snow Leopard: if one of my Macs get disconnected from my wireless network, it won’t reconnect automatically. Since I’m running my Mac mini without a display or keyboard connected, that means I have to plug them in just to fix the problem. (Normally I just connect with Screen Sharing, but clearly I can’t do that if it’s not on the network.)
I’ve tried an endless number of things to fix the problem. AirPort is set as the first connection type to try, and my network is in the list of Preferred Networks. It connects fine after booting up, but never after the connection is lost. So I’m pretty sure this is a bug, and it will probably get fixed in 10.6.2 or some other update—hopefully soon.
I got tired of waiting for a fix though, so I wrote an AppleScript to solve the problem. This script will check if your Mac is connected to a network. If it’s not, it will connect to the network you specify in the first line.
set theNetwork to "NetworkName"
tell application "System Events"
tell process "SystemUIServer"
set menuItems to menu bar items of menu bar 1
repeat with menuItem in menuItems
if description of menuItem is "AirPort Menu Extra" then set theStatus to value of menuItem
end repeat
end tell
if theStatus is "No Signal" then
tell application "System Preferences" to set current pane to pane id "com.apple.preference.network"
tell process "System Preferences"
set networkServices to rows of table 1 of scroll area 1 of window 1
repeat with networkService in networkServices
if "AirPort" is in (value of static text 1 of networkService) then
select networkService
delay 3
click pop up button 1 of group 1 of window "Network"
set menuItems to menu items of menu 1 of pop up button 1 of group 1 of window "Network"
repeat with menuItem in menuItems
if (title of menuItem is theNetwork) then
click menuItem
exit repeat
end if
end repeat
end if
end repeat
end tell
tell application "System Preferences" to quit
end if
end tell
You can download the script here. After you download it you’ll need to open it in AppleScript Editor and edit the first line. Change NetworkName to the actual name of your network (the SSID). This script also requires you to enable GUI scripting—just open System Preferences, click Universal Access, then check “Enable access for assistive devices” at the bottom.
In order to make the script really useful, you’ll also need to set it to run periodically. One of the easiest ways to do this is to download Lingon. (Click the link with a name like “Lingon-2.1.1.zip”, not the “LingonSource-2.1.1.zip” one.) After you download Lingon and move it to your Applications folder, open it up.
Once Lingon is open, click the New button. Fill out the settings like this:
Make sure the path is correct in the “What” section. If you place the Network.scpt file in your Documents folder, then enter the same path that’s in the example, but change “mike” to your own short user name (the name of your home folder). If you like you can adjust the script to run more or less often. 3 minutes works pretty well for me.
Click the Save button when you’re done. After that you’ll need to log out (through the Apple menu) and then log back in. Or you can just restart your computer. If you’ve set everything up correctly, you’re done.
This is far from an ideal solution, of course, but until Apple fixes the problem it should make my life a lot less frustrating. Hopefully it will help some of you too!
View more
Mac
An update on our apps It’s been a while since we shared an update on everything we’re working on. With iOS 15…
Upcoming changes to Deliveries Deliveries 9.2 will be available soon, and we wanted to let you know about some changes…
Deliveries 9 will arrive September 30 Deliveries 9 will be available this Wednesday, September 30, for iPhone, iPad, Apple…
Comments
This entry has 2 comments.
Collin Henderson wrote on October 13, 2009:
Nice post Mike, I could see this being very handy. Thanks a lot for the script :)
dbarnes wrote on October 22, 2009:
Thanks for posting this. I’m running it on my MacBook C2D with Snow Leopard (upgraded from Tiger). But instead of getting my wireless network connected as specified in my configured version of the script, I’m getting a pop-up menu of wireless networks appearing in the middle of my screen. Looks like the universal access thing isn’t working quite right. I do have universal access turned on. When I choose my network from the pop-up list, the connection isn’t made. Manual connections using the menu bar widget continue to work fine. Not a big issue here. Suggestions welcome. Mostly FYI.