Merge pull request #1004 from fewtarius/dev

Add a simple service to autoconnect paired bluetooth devices.
This commit is contained in:
fewtarius 2023-01-26 20:14:58 -05:00 committed by GitHub
commit 56a7f10c64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 7 deletions

View file

@ -6,6 +6,7 @@ if [ "$(get_setting bluetooth.enabled)" == "1" ]
then
nohup systemctl start bluetooth &
nohup systemctl start bluetooth-agent &
nohup systemctl start bluetoothsense &
rfkill unblock bluetooth
else
rfkill block bluetooth

View file

@ -20,6 +20,7 @@ makeinstall_target() {
cp ${PKG_DIR}/sources/scripts/headphone_sense ${INSTALL}/usr/bin
cp ${PKG_DIR}/sources/scripts/system_utils ${INSTALL}/usr/bin
cp ${PKG_DIR}/sources/scripts/volume_sense ${INSTALL}/usr/bin
cp ${PKG_DIR}/sources/scripts/bluetooth_sense ${INSTALL}/usr/bin
if [ -d "${PKG_DIR}/sources/devices/${DEVICE}" ]
then
cp ${PKG_DIR}/sources/devices/${DEVICE}/* ${INSTALL}/usr/bin
@ -35,3 +36,7 @@ makeinstall_target() {
mkdir -p ${INSTALL}/usr/config
cp ${PKG_DIR}/sources/config/fancontrol.conf ${INSTALL}/usr/config/fancontrol.conf.sample
}
post_install() {
enable_service volume.service
}

View file

@ -18,9 +18,3 @@ else
nohup systemctl stop headphones &
fi
if [ "${DEVICE_VOLUMECTL}" == "true" ]
then
nohup systemctl start volume &
else
nohup systemctl stop volume &
fi

View file

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

View file

@ -0,0 +1,12 @@
[Unit]
Description=Bluetooth Sense
Before=jelos.target
[Service]
Environment=HOME=/storage
EnvironmentFile=/etc/profile
ExecStart=/usr/bin/bluetooth_sense
Restart=on-failure
[Install]
WantedBy=multi-user.target

View file

@ -3,7 +3,7 @@
# Copyright (C) 2020-present Fewtarius
PKG_NAME="emulationstation"
PKG_VERSION="87e72ff"
PKG_VERSION="67ebda6"
PKG_GIT_CLONE_BRANCH="main"
PKG_REV="1"
PKG_ARCH="any"