Welcome to Apple Support Communities. We're all users here.
Sorry, I can't help with re-defining function keys, but one solution is only a mouse-click away.
, System Preferences, Internet & Wireless, Network, to enable the AirPort icon in the top menubar
Then clicking the icon allows you to turn AirPort on or off easily.
Of course I know that but that's totally not what I'm looking for. Using the mouse SLOWS you down! Therefore I want a shortcut or a button that I can use
Just curious, why and how often would you need to do this that would require something like a shortcut to speed it up? And I don't think there is a way to do this from the keyboard. However:
from Terminal it's
networksetup -setairportpower airport off or on
Could possibly write a script to do that which is controlled by a shortcut. Don't ask me how.
Network Setup Assistant.app lives in /System/Library/CoreServices
Message was edited by: WZZZ
Ok, I'll satisfy your curiosity. I'm using my MBP on the go all the time and I'm relying on my LTE hotspot connection of my iphone. It seems that it doesn't automatically recognises the connection and so I have to turn it off and on many times before it gets smart and automatically picks my connection. So whilst I'm working I don't want to go and use my mouse to manually toggle the thing on or off so a simply hit on a button will suffice and in the mean time I can keep doing what I'm doing until it has established the correct connection. It's a bit frustrating though but that's how it is. I'll check out your idea and I think I've used 'spark' before somewhere in the past. I'll get back to you on this.
I have the feeling that, even if you could write a script or set that script to some keyboard combination, it might take just as long to execute as having to go to the Airport icon.
Maybe the real solution is to get Airport on the MBP to work better with your iPhone hotspot. I know nothing about that, but you might try posting in the iPhone forum.
Since nobody has posted a solution, here's one way to do it, expanding upon WZZZ's answer above should actually be:
networksetup -setairportpower en1 off
networksetup -setairportpower en1 on
where en1 is the Interface Name of your Wi-Fi device. It was en1 on my laptop, but you can check and be sure using:
Also, you can toggle it if you grep the current state using -getairportpower first. Here's the full command to toggle Wi-Fi state on and off (the whole thing is one long line):
networksetup -getairportpower en1 | grep "On" && networksetup -setairportpower en1 off || networksetup -setairportpower en1 on
But typing it every time into Terminal is no good, so here's how you create a keyboard shortcut that runs a shell command:
1. Start Automator, and create a new Service.
2. Set "Service receives selected: to "no input" in "any application".
3. Add an action named "Run Shell Script". It's in the Utilities section of the Actions Library.
4. Insert the bash command you want into the text box and test run it using the Run button (top right). It should do whatever the script does (off, on or toggle), and there should be green ticks below the Action.
5. Save it, giving it a service name you can remember.
6. Go to System Preferences -> Keyboard, and go to the Shortcuts tab
7. Go to the Services section, and scroll down to General - you should find your service there. If you select the line, you can click "add shortcut" and give it a keyboard shortcut.
The shortcut key will now trigger whatever command you set up earlier, no matter what app you're in, but shortcuts from the app take priority (so if your hotkey clashes with a hotkey in the app you're currently running, the app's hotkey will trigger).
Also, I don't think you can use any of the function keys. I don't know why, but I've never had those ever work, even with the Fn key. Command Shift A or something like that works fine.
You can always execute this via a voice trigger command. Depending on your operating system that is either Apple menu -> System Preferences -> Speech or Universal Access. And you have an option "Say a command." And that would execute that command as a speech command, if you have a script file already written to do it.
Here's a really cool FREE solution that I came up with. It requires having BetterTouchTool installed on your computer, and about 10 minutes to set it up within BetterTouchTool.