12 Replies Latest reply: Aug 1, 2014 3:06 AM by Zapko-tcs
BassPlaya Level 1 Level 1 (0 points)

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)
  • kostby Level 4 Level 4 (2,615 points)

    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

     

    Screen shot 2013-06-03 at 9.15.47 PM.png

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

    Screen shot 2013-06-03 at 9.17.26 PM.png

  • BassPlaya Level 1 Level 1 (0 points)

    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.

  • WZZZ Level 6 Level 6 (12,640 points)

    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

  • WZZZ Level 6 Level 6 (12,640 points)

    Correction, it's probably controlled by networksetup, not Network Setup Assistant

     

    /usr/sbin/networksetup

  • BassPlaya Level 1 Level 1 (0 points)

    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.

  • WZZZ Level 6 Level 6 (12,640 points)

    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

  • WZZZ Level 6 Level 6 (12,640 points)

    The other possibility is to set up a new location in Sys Prefs>Network, using the same settings. That sometimes helps in this situation. Maybe also change channels on the iPhone hotspot, if that's possible. But the iPhone people should know more.

  • budakpisang Level 1 Level 1 (0 points)

    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.

  • a brody Level 9 Level 9 (64,210 points)

    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.

  • rennyz27 Level 1 Level 1 (5 points)

    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.

     

    http://arsnovaproductions.wordpress.com

  • Zapko-tcs Level 1 Level 1 (0 points)

    Cool! Thank you!