Last active
September 10, 2024 04:27
-
-
Save sofakartoffel/5175899 to your computer and use it in GitHub Desktop.
OSX seems to set 802.11d country code upon the first found network's country code. This might not be the correct one, depending on your or your neighbors' settings. This script restarts your Wi-Fi until (or 10 times) the correct country code is set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- This does not work if you need administrator privilieges for setting Wi-Fi power | |
| set correctcountrycode to "DE" | |
| repeat 10 times | |
| set countrycode to do shell script "system_profiler SPAirPortDataType -xml | xmllint --dropdtd - | xpath '//key[text()=\"spairport_wireless_country_code\"]/following-sibling::string[1]/text()'" | |
| if countrycode = correctcountrycode then exit repeat | |
| do shell script "networksetup -setairportpower en1 off" | |
| delay 6 | |
| do shell script "networksetup -setairportpower en1 on" | |
| delay 2 | |
| end repeat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this works in Mountain Lion - I switched correct country code for bad one, as my cosmopolitan neighbourhood has a friendly DE router and bane-of-my-existence TW router, which invariably gets picked up by airport and takes out my 5ghz channels.