distribution/packages/sysutils/system-utils/sources/scripts/bluetooth_sense
2023-08-11 00:13:00 +00:00

24 lines
628 B
Bash
Executable file

#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2020-present Fewtarius
# Source predefined functions and variables
. /etc/profile
while true
do
if [ "$(/usr/bin/bluetoothctl show | awk '/Powered:/ {print $2}' 2>/dev/null)" = "yes" ]
then
for DEVICE in $(/usr/bin/bluetoothctl devices Paired 2>&1 | awk '{print $2}' 2>/dev/null)
do
CONNECTED=$(/usr/bin/bluetoothctl devices Connected 2>&1 | grep ${DEVICE} 2>/dev/null)
if [ -z "${CONNECTED}" ]
then
/usr/bin/bluetoothctl --timeout 5 connect ${DEVICE} >/dev/null 2>&1
fi
sleep .5
done
fi
sleep 5
done