Port connection-counting x4 bluetooth sensor to x2
[khatus.git] / x2 / src / bash / exe / khatus_sensor_bluetooth.sh
CommitLineData
b9592ab6
SK
1#! /bin/sh
2
3set -e
4
5# TODO: Centralize the definitions of the constants, as in AWK code.
6FS1='|' # Fields separator, level 1 (a record's fields)
7FS2=':' # Fields separator, level 2 (a field's subfields)
8
9count_powered_controllers() {
10 bluetoothctl -- show | grep -c 'Powered: yes'
11}
12
13count_connected_devices() {
14 bluetoothctl -- paired-devices \
15 | awk '{print $2}' \
16 | xargs -I % bluetoothctl -- info % \
17 | grep -c 'Connected: yes'
18}
19
20printf "%s%s%d\n" 'count_powered_controllers' "$FS1" "$(count_powered_controllers)"
21printf "%s%s%d\n" 'count_connected_devices' "$FS1" "$(count_connected_devices)"
This page took 0.024315 seconds and 4 git commands to generate.