You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to create shortcut to turn on/off Wifi in Snow Leopard

I want to use the F5 key on my MBP to turn on Wifi with a single hit on the keyboard and turn it off again with a single hit using F6. Is this possible? I've tried to do it under Preferences/Keyboard/Keyboard Shortcuts but I can't add F5 (not by typing and not by hitting that button). That button seems to be dedicated for the illumination of the keyboard. How can I change these settings so that I can have my fast function key at my disposal.


Cheers,

BassPlaya

MacBook Pro, Mac OS X (10.6.8)

Posted on Jun 3, 2013 4:51 AM

Reply
16 replies

Jul 17, 2017 5:03 AM in response to budakpisang

Thanks so much for this! Now i can connect to my preferred wifi network with Command-Control-W if i happen to turn my laptop on before turning my phone's hotspot on. This is a big convenience because in this scenario it wont connect to the hotspot automatically (at least not in a timely manner) and i have to click the airport icon two times to first make it visible in the list and then select it. The script i'm using is:

networksetup -setairportpower en0 off

networksetup -setairportpower en0 on

Awesome!

Jun 3, 2013 6:25 PM in response to BassPlaya

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


User uploaded file

Then clicking the icon allows you to turn AirPort on or off easily.

User uploaded file

Jun 4, 2013 5:15 AM in response to BassPlaya

BassPlaya wrote:


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

Jun 4, 2013 8:19 AM in response to 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.


Cheers.

Jun 4, 2013 8:26 AM in response to BassPlaya

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.


https://discussions.apple.com/community/iphone/using_iphone

Apr 5, 2015 5:14 AM in response to BassPlaya

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:

networksetup -listnetworkserviceorder


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.

How to create shortcut to turn on/off Wifi in Snow Leopard

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.