3

This question already has an answer here:

My work involves trying stuff online and offline, on a Mac. Sometimes a try can be less than 10 seconds of needed offline time. Most of the time I still need to be online.

Instead of going to Network -> Ethernet/Wifi and disable everything manually, I'd like to know if there is a way to disable it all at once, and re-enable it just as easily.

I've also simply removed the ethernet cable for a while but that's just ridiculously annoying. Since I'm working on a Mac Mini, that also forces me to have it's back facing me for easier reach, and all cables lying just under my screen/behind my keyboard. While that is an "okay" option, I'd like to get rid of it.

I'm thinking maybe there is an App that could be on the top bar and I'd just tap On/Off.

I already use the NetworkConditioner which is amazing for simulating lag, but the only "offline" I can get here is just "100% packet loss" which isn't really offline, it's just infinite lag.

If you have an easy on/off switch (ideally on the top bar so I don't have to Alt-Tab between apps) or something similar to airplane mode, I'm all ears !

marked as duplicate by dan, user151019, grg osx May 20 '16 at 19:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    Might be a dupe, but this answer is so much easier to understand ;-) – Tetsujin May 20 '16 at 10:11
  • I've brought up merging the two questions in chat. (cc @Tetsujin) – grg May 20 '16 at 19:47
  • @grgarside - that would be a great idea, George :) – Tetsujin May 20 '16 at 20:19
4

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 :

  1. Create a simple shell script, like your example I've made a Hello World application:

    #!/bin/bash
    networksetup -switchtolocation AirplaneMode 
    
  2. Save this file as HelloWorld.command. Give this file permission to be executed. chmod u+x HelloWorld.command should do that.

  3. Open the directory where you saved this file in Finder.

  4. 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.

  • 1
    To add on, you could further simplify the process by adding two desktop Terminal files which automatically execute the command. – Brick May 20 '16 at 11:44
  • 1
    I like this idea. Didn't think of that, thanks man ;) – Gil Sand May 20 '16 at 11:44
  • Yep, why don't you add the steps in your answer or provide a link? That would improve your answer. – Brick May 20 '16 at 11:45
  • Haha give me a second :P – Gil Sand May 20 '16 at 11:45
  • You can use Automator to save the scripts as Services then map keyboard commands to them within the keyboard System Preferences. Way easier than coding up some menu bar item. – Brian M. May 20 '16 at 13:38
0

I made a configuration which is a sort of Airplane mode for Mac OS X, and am regularly using since more than 10 years with no problem and a lot of advantages (when under attack, when troubleshooting a process with network problems...).

See: Airplane mode for MacOS X

  • Eh, couldn't you just copy-paste the answer here? That would help. – Brick May 20 '16 at 11:47
  • No need : it's just an internal link as you might have discovered :). – dan May 20 '16 at 16:03
-2

why not just remove the Ethernet cable and only connect via WiFi which is so easy, just turn Airport off when you don't want to be connected from the menu bar. Sorted

  • Because @Zil (3rd §) just explained why this is what he would like to avoid. – dan May 20 '16 at 10:26

Not the answer you're looking for? Browse other questions tagged .