Merge pull request #1004 from fewtarius/dev
Add a simple service to autoconnect paired bluetooth devices.
This commit is contained in:
commit
56a7f10c64
6 changed files with 43 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
24
packages/sysutils/system-utils/sources/scripts/bluetooth_sense
Executable file
24
packages/sysutils/system-utils/sources/scripts/bluetooth_sense
Executable 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
|
|
@ -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
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue