Created
October 16, 2019 19:42
-
-
Save Zetaphor/5451470a22a197e9f80f13fb38f1b5c4 to your computer and use it in GitHub Desktop.
Automatically reconnect bluetooth headphones
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
##### CONFIGURATION ##### | |
MAC="E8:EC:A3:30:0C:62" | |
MODE="connect" | |
######################### | |
STATUS=$(bluetoothctl info $MAC | grep "Connected" | awk '{print $2}') | |
case $1 in | |
on|enable) | |
MODE="connect" | |
;; | |
off|disable) | |
MODE="disconnect" | |
;; | |
t|toggle) | |
echo $STATUS | grep "yes" # Check if already connected | |
if [ $? == 0 ]; | |
then | |
MODE="disconnect" | |
else | |
MODE="connect" | |
fi | |
;; | |
esac | |
bluetoothctl << EOF | |
$MODE $MAC | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment