distribution/packages/sysutils/system-utils/sources/scripts/bluetooth_sense

28 lines
725 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
if [ "$?" = "0" ]
then
volume $(get_setting "audio.volume")
fi
fi
sleep .5
done
fi
sleep 5
done