Guest User

bt-toggle.sh

a guest
Jan 31st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ## Bluetooth toggle
  4.  
  5. BTSTATE=$(connmanctl technologies | sed -n -e '/bluetooth/,+5p' | grep Powered | awk '{print $3; exit}')
  6.  
  7. # Toggle Bluetooth
  8.  
  9. case "$1" in
  10. "toggle")
  11. if [ "$BTSTATE" == "False" ] ; then
  12. echo 0 > /proc/bluetooth/sleep/lpm && dbus-send --system --print-reply --dest=net.connman /net/connman/technology/bluetooth net.connman.Technology.SetProperty string:"Powered" variant:boolean:true
  13.  
  14. else
  15. dbus-send --system --print-reply --dest=net.connman /net/connman/technology/bluetooth net.connman.Technology.SetProperty string:"Powered" variant:boolean:false && echo 1 > /proc/bluetooth/sleep/lpm
  16. fi
  17. ;;
  18. esac
  19.  
  20. exit 0
Add Comment
Please, Sign In to add comment