Como posso configurar um atalho de teclado para alternar o aeroporto (placa wifi) no OS X? [duplicado]

4

Como posso configurar um atalho de teclado para alternar o aeroporto (ligado / desligado) no OS X?

    
por cwd 04.11.2011 / 13:58

3 respostas

4

Com base em uma pergunta semelhante Como podemos Redefinir as conexões de rede (aeroporto) da linha de comando?

Crie dois arquivos applescript:

do shell script "/usr/sbin/networksetup -setairportpower en1 on"
do shell script "/usr/sbin/networksetup -setairportpower en1 off"

Em seguida, use fastscripts para atribuir atalhos de teclado a eles.

    
por 04.11.2011 / 15:34
2

Eu encontrei este :

Toggle AirPort on and off using keyboard shortcuts
Oct 17, '08 07:30:03AM • Contributed by: Anonymous

This is the simplest way I've found to toggle the AirPort card on and off without using third party applications or too many buttons. Hopefully others will appreciate this function as I do. Note: This function is tailored to a MacBook, as the F5 and F6 keys have no predetermined function on these machines. Other machines may need the shortcut keys to be edited.

1- Create two keyboard shortcuts. Go to the Apple menu » System Preferences » Keyboard & Mouse » Keyboard Shortcuts tab. Click the plus sign at the bottom of the window, and select All Applications from the pop-up menu in the next dialog. In the Menu Title box, type Turn AirPort On with that exact case and spelling. Set the Keyboard Shortcut to F5, then click Add. Click the plus sign again, leave the pop-up menu set to All Applications, and in the Menu Title box, type Turn AirPort Off with the shortcut key also set to F5 -- only one of these functions will be displayed at a time.

2 - In the Keyboard Navigation section of the same window, change the 'Move focus to status menus in the menu bar' to F6 (and check the box to enable this shortcut, if it's not yet enabled).

3 - Make sure the AirPort icon is in your menu bar. Then hold down the Command key and drag the AirPort Menu bar icon as far to the left as possible. This insures that it is the first to be selected when you move focus to the menu bar.

4 - Finally, restart your system. After your Mac reboots, press F6 to move focus to the menu bar, and F5 to toggle AirPort on or off, depending on its current state.

Além do problema de arrastar para a posição mais à esquerda (como outros "atalhos" do Mac exigem essa mesma posição), isso deve funcionar bem.

    
por 04.11.2011 / 14:15
2
#!/bin/sh

device="$(networksetup -listallhardwareports |
grep -E '(AirPort|Wi-Fi)' -A 1 | grep -o "en.")"
[[ "$(networksetup -getairportpower $device)" == *On ]] && val=off || val=on
networksetup -setairportpower $device $val
    
por 04.11.2011 / 18:43