aboutsummaryrefslogtreecommitdiff
path: root/linux-bin/blu
blob: c02eb3049df3cd4a05e1476f2aed05fdc3df3bc4 (plain) (blame)
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
#!/bin/sh
# Small bluetooth wrapper to make common tasks more friendly.
set -e

getDevice() {
	bluetoothctl devices Paired | grep "$1" | sed 1q | awk '{print $2}'
}

if [ $# -eq 0 ] ; then
	bluetoothctl devices Paired
	exit 0;
fi

case $1 in
on|up)
 bluetoothctl power on
;;
off|down)
 bluetoothctl power off
;;
c*)
 shift;
 device="$(getDevice "$1")"; shift;
 bluetoothctl connect "$device" "$@"
;;
d*)
 shift;
 device="$(getDevice "$1")"; shift;
 bluetoothctl disconnect "$device" "$@"
;;
t*)
 shift;
 device="$(getDevice "$1")"; shift;
 bluetoothctl trust "$device" "$@"
;;
b*)
 shift;
 device="$(getDevice "$1")"; shift;
 bluetoothctl block "$device" "$@"
;;
ub*|unblock)
 shift;
 device="$(getDevice "$1")"; shift;
 bluetoothctl unblock "$device" "$@"
;;
esac