phil
New Droid
Posts: 7
|
Post by phil on Dec 10, 2014 16:31:29 GMT
Copy the script below into DisplayDroid's editor window and choose 'Set Default'.
When a Display is connected or disconnected, the script will run (see comments at the beginning of the script for more details).
#Adapted from here: http://techyvish.com/apple-script-to-change-wifi-toggle-wifi/
#This will turn your wifi OFF when you disconnect a display , and ON when you connect one #replace "removed" with "added" if you want the opposite effect
#IMPORTANT: you must supply the Wifi name (SSID) and its password or the script will throw a runtime error
on toggleWifi(value, device) do shell script ("/usr/sbin/networksetup -setairportpower " & device & " " & value) end toggleWifi
set airPortDevice to do shell script "/usr/sbin/networksetup -listallhardwareports | awk '{if($3==\"Wi-Fi\"){getline;print}}' | awk '{print $2}'"
if displayState = "removed" then toggleWifi("off", airPortDevice) set apStatus to false else toggleWifi("on", airPortDevice) set apStatus to true do shell script ("networksetup -setairportnetwork en1 '<your SSID>' <your wifi password>") end if
|
|