forked from rgcr/m-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflightmode
executable file
·50 lines (34 loc) · 860 Bytes
/
flightmode
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
_W_DEVICE=${_W_DEVICE:-en0}
help(){
cat<<__EOF__
usage: m flightmode [ on | off | help ]
Examples:
m flightmode off # turn flightmode off
m flightmode on # turn flightmode on
__EOF__
}
flightmode_on(){
networksetup -setairportpower ${_W_DEVICE} off
sudo defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerState -int 0 && \
sudo killall -HUP blued
}
flightmode_off(){
networksetup -setairportpower ${_W_DEVICE} on
sudo defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerState -int 1 && \
sudo killall -HUP blued
}
case $1 in
help)
help
;;
off)
flightmode_off
;;
on)
flightmode_on
;;
*)
help
;;
esac