Easily disable/enable all network connectivity [duplicate]
Damnit. I searched for a while but without using the keywords "airplane mode osx" which only came to me when I edited my question here.
Research using these words led to a very useful answer available here :
http://hints.macworld.com/article.php?story=20130325002258846
If you go to the Network pane of System Preferences, you'll see a Location popup menu at the top of the window. Click on that menu and choose Edit Locations. Click on the + icon to add a new location, then enter a name, such as AirplaneMode. Click on Done.
Next, choose that location in the Location menu, and click on each available network interface in the list at the left of the window. Click on the Configure iPv4 menu, and choose Off. For Wi-Fi, just click on the Turn Wi-Fi Off button. Click Apply, and this location will block all network activity.
To activate the location, there are two ways. You can click on the Apple menu, then Location, and choose the location. Or, if you wish to do this from the command line, as the poster had requested, you can run this command:
networksetup -switchtolocation AirplaneMode
Replace AirplaneMode with the name you've chosen for the location.
Note : If you've never used the Locations, it won't appear in the Apple menu ; it will appear the first time you make a switch, either using the command line or the Locations menu from the network pane in the settings.
Also, making this process easier could be done by adding two terminal files that execute each command separetely. That can be found here
Here is a summary of the steps found behind that link :
-
Create a simple shell script, like your example I've made a Hello World application:
#!/bin/bash networksetup -switchtolocation AirplaneMode
-
Save this file as HelloWorld.command. Give this file permission to be executed.
chmod u+x HelloWorld.command
should do that. -
Open the directory where you saved this file in Finder.
-
Double click on the HelloWorld.command file.
Now all I need is a way to hit those shortcuts from the menu bar and I'm golden. I'll edit here if I find it, but I think I might have to develop it myself.