-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblpair
More file actions
executable file
·36 lines (32 loc) · 738 Bytes
/
blpair
File metadata and controls
executable file
·36 lines (32 loc) · 738 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
32
33
34
35
36
#!/bin/sh
# Connect to my bluetooth earphones
right="8C:85:80:56:EC:97"
left="8C:85:80:57:34:08"
# If the -l flag is set, use the left earphone
if [ "$1" = "-l" ] || [ "$2" = "-l" ]; then
echo "Using left earphone"
mac=$left
else
echo "Using right earphone"
mac=$right
fi
# If the -d flag is set as the first or second argument,
# disconnect the earphones
if [ "$1" = "-d" ] || [ "$2" = "-d" ]; then
bluetoothctl << EOF
disconnect $mac
EOF
# If the -r flag is set as the first or second argument,
# remove the earphones
elif [ "$1" = "-r" ] || [ "$2" = "-r" ]; then
bluetoothctl << EOF
remove $mac
EOF
# Otherwise, connect to the earphones
else
bluetoothctl << EOF
trust $mac
pair $mac
connect $mac
EOF
fi