-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwifi.sh
More file actions
executable file
·31 lines (31 loc) · 884 Bytes
/
wifi.sh
File metadata and controls
executable file
·31 lines (31 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
#######################################################################
# wifi.sh
# arielvb - http://www.arielvb.com
# Enable or Disable Airport (Macbook's Wifi)
# version: 0.1
# Usage: wifi [on|off]
# Changelog:
# 0.1 first version
#######################################################################
DEVICENAME=en0
CURRENT=`networksetup -getairportpower $DEVICENAME | grep On`;
if [[ $BASH_ARGC < 0 ]]; then
if [[ $CURRENT ]]; then
echo 'Status: on'
else
echo 'Status: off'
fi
exit
fi
if [[ ($1 == 'on') && ($CURRENT == "") ]]; then
networksetup -setairportpower $DEVICENAME on
echo 'Wifi on'
elif [[ ($1 == 'off') && ($CURRENT) ]]; then
networksetup -setairportpower $DEVICENAME off
echo 'Wifi off'
elif [[ ($1 == 'reset') ]]; then
networksetup -setairportpower $DEVICENAME off
networksetup -setairportpower $DEVICENAME on
echo 'Wifi reset'
fi