X-Git-Url: https://git.xandkar.net/?p=khatus.git;a=blobdiff_plain;f=x4%2Fbin%2Fkhatus_x4_sensor_bluetooth;fp=x4%2Fbin%2Fkhatus_x4_sensor_bluetooth;h=96d28a8c9f9a6c541b385a9de41d0c0f9da66271;hp=0000000000000000000000000000000000000000;hb=3565cd1da64d6d0d273476e6bd94a83cd65d4b0e;hpb=1fd28945d92907f2c228e3a39ae7f7c649cce6b0 diff --git a/x4/bin/khatus_x4_sensor_bluetooth b/x4/bin/khatus_x4_sensor_bluetooth new file mode 100755 index 0000000..96d28a8 --- /dev/null +++ b/x4/bin/khatus_x4_sensor_bluetooth @@ -0,0 +1,23 @@ +#! /bin/sh + +set -e + +. "$(dirname $(realpath $0))/khatus_x4_lib_common_sensor.sh" + +count_powered_controllers() { + bluetoothctl -- show | grep -c 'Powered: yes' +} + +count_connected_devices() { + bluetoothctl -- paired-devices \ + | awk '{print $2}' \ + | xargs -I % bluetoothctl -- info % \ + | grep -c 'Connected: yes' +} + +sensor() { + printf "count_powered_controllers %d\n" $(count_powered_controllers) + printf "count_connected_devices %d\n" $(count_connected_devices) +} + +run