eprev / locationchanger

Change OS X’s network location based on the name of Wi-Fi network
404 stars 67 forks source link

Mac OS Big Sur #21

Closed sylwester- closed 3 years ago

sylwester- commented 4 years ago

Fantastic script! Worked like a charm on Catalina.

On the Big Sur beta I get the following error:

Load failed: 5: Input/output error

eprev commented 4 years ago

Thanks for the report!

pbernicchi commented 3 years ago

I've used locationchanger for years. I can echo the issue @sylwester- reported. Things just stopped under Big Sur. I manually reinstalled the script into /usr/local/bin (on top of my existing). Manually running sudo launchctl load ~/Library/LaunchAgents/LocationChanger.plist has no effect. I can run the script and it will throw the location notification in system.log but neither switches location nor fires the corresponding script in ~/.locations. Happy to help troubleshoot.

eprev commented 3 years ago

Looks like Big Sur stopped writing to com.apple.airport.preferences.plist on Wi-Fi changes.

@pbernicchi could you confirm if changing /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist (line 13) in ~/Library/LaunchAgents/LocationChanger.plist to /Library/Preferences/SystemConfiguration makes it work again?

As for Load failed: 5: Input/output error error (/c @sylwester-), it seems like Big Sur now loads plist's only when they are owned by the root user. This should help:

sudo chown root:wheel ~/Library/LaunchAgents/LocationChanger.plist
sudo launchctl load ~/Library/LaunchAgents/LocationChanger.plist

I'll change the installation script to create that plist in the system library.

eprev commented 3 years ago

Though if it runs as root, then it won’t run user’s scripts. I am running out of ideas.

ksu-x commented 3 years ago

Though if it runs as root, then it won’t run user’s scripts. I am running out of ideas.

Same problem, Is there any way to fix it ?

pbernicchi commented 3 years ago

@eprev Looks like monitoring /Library/Preferences/SystemConfiguration did work as the script is (aggressively, I might add - this isn't a bad thing) picking up on the SSID change and changing location. No evidence that user scripts are being executed as you note.

kjyv commented 3 years ago

Instead of a user script you could also base the network changing on this script (been using that for years and it still works): http://hints.macworld.com/article.php?story=2005010613401823

eprev commented 3 years ago

@sylwester- @pbernicchi @Lesen1991 Please update (reboot may be required), managed to fix the issue:

$ launchctl unload  $HOME/Library/LaunchAgents/LocationChanger.plist
$ curl -L https://github.com/eprev/locationchanger/raw/master/locationchanger.sh | bash