Skip to content

Commit

Permalink
Merge pull request #126 from mogutan88/bluetooth-support-sierra
Browse files Browse the repository at this point in the history
bluetooth command to support sierra and high sierra
  • Loading branch information
rgcr committed Aug 2, 2018
2 parents 3d9a4e8 + f05b555 commit d68cf9f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
4 changes: 3 additions & 1 deletion Readme.md
Expand Up @@ -91,11 +91,13 @@ usage: m [OPTIONS] COMMAND [help]

#### Bluetooth:
```
usage: m bluetooth [ status | enable | disable | help ]
usage: m bluetooth [ status | on | enable | off | disable | help ]
Examples:
m bluetooth status # bluetooth status
m bluetooth on # turn on bluetooth
m bluetooth enable # turn on bluetooth
m bluetooth off # turn off bluetooth
m bluetooth disable # turn off bluetooth
```

Expand Down
2 changes: 1 addition & 1 deletion completion/bash/m
Expand Up @@ -10,7 +10,7 @@ _m_sub () {
subcommands=(status help)
;;
bluetooth)
subcommands=(status enable disable help)
subcommands=(status on enable off disable help)
;;
dir)
subcommands=(tree size delete help)
Expand Down
2 changes: 2 additions & 0 deletions completion/fish/m.fish
Expand Up @@ -42,7 +42,9 @@ complete -f -c m -n '__fish_m_using_command battery' -a "help" -d 'Show help'

## XXX:
complete -f -c m -n '__fish_m_needs_command' -a bluetooth -d 'Manage bluetooth status'
complete -f -c m -n '__fish_m_using_command bluetooth' -a "on" -d 'turn on bluetooth'
complete -f -c m -n '__fish_m_using_command bluetooth' -a "enable" -d 'turn on bluetooth'
complete -f -c m -n '__fish_m_using_command bluetooth' -a "off" -d 'turn off bluetooth'
complete -f -c m -n '__fish_m_using_command bluetooth' -a "disable" -d 'turn off bluetooth'
complete -f -c m -n '__fish_m_using_command bluetooth' -a "help" -d 'Show help'

Expand Down
2 changes: 2 additions & 0 deletions completion/zsh/_m
Expand Up @@ -382,7 +382,9 @@ function _m_cmd {
_m_solo \
$sub \
"status:bluetooth status" \
"on:turn on bluetooth" \
"enable:turn on bluetooth" \
"off:turn off bluetooth" \
"disable:turn off bluetooth" \
help
;;
Expand Down
14 changes: 9 additions & 5 deletions plugins/bluetooth
Expand Up @@ -2,15 +2,19 @@

help(){
cat<<__EOF__
usage: m bluetooth [ status | enable | disable | help ]
usage: m bluetooth [ status | on | enable | off | disable | help ]
Examples:
m bluetooth status # bluetooth status
m bluetooth on # turn on bluetooth
m bluetooth enable # turn on bluetooth
m bluetooth off # turn off bluetooth
m bluetooth disable # turn off bluetooth
__EOF__
}

DAEMON=`[ -e /usr/sbin/bluetoothd ] && echo bluetoothd || echo blued`

case $1 in
help)
help
Expand All @@ -19,13 +23,13 @@ case $1 in
defaults read /Library/Preferences/com.apple.Bluetooth ControllerPowerState | \
awk '{ if($1 != 0) {print "Bluetooth: ON"} else { print "Bluetooth: OFF" } }'
;;
enable)
on|enable)
sudo defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerState -int 1 && \
sudo killall -HUP blued
sudo killall -HUP ${DAEMON}
;;
disable)
off|disable)
sudo defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerState -int 0 && \
sudo killall -HUP blued
sudo killall -HUP ${DAEMON}
;;
*)
help
Expand Down

0 comments on commit d68cf9f

Please sign in to comment.