#!/bin/bash
echo "=== find bluetoothd ==="
ACTUAL=$(ls /usr/lib/bluetooth/bluetoothd /usr/libexec/bluetooth/bluetoothd 2>/dev/null | head -1)
echo "bluetoothd = $ACTUAL"
sudo mkdir -p /etc/systemd/system/bluetooth.service.d
printf '[Service]\nExecStart=\nExecStart=%s --experimental\n' "$ACTUAL" | sudo tee /etc/systemd/system/bluetooth.service.d/exp.conf >/dev/null
sudo systemctl daemon-reload
sudo systemctl restart bluetooth
sleep 4
echo "=== bluetoothd cmdline (ждём --experimental) ==="
ps -eo args | grep bluetoothd | grep -v grep
echo "=== restart improv (bless) ==="
sudo systemctl restart mp-improv
sleep 6
echo "=== bless registered advertisement? (ждём непусто) ==="
sudo busctl tree org.bluez 2>/dev/null | grep -i advertis
echo "=== current settings (ждём advertising) ==="
sudo btmgmt info 2>/dev/null | grep -i 'current settings'
echo "=== improv journal last 6 ==="
sudo journalctl -u mp-improv --no-pager -n 6
