fix: robust connected device resolution and aggressive process restart
This commit is contained in:
parent
a444501b06
commit
38043b33c8
2 changed files with 8 additions and 5 deletions
|
|
@ -79,7 +79,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
return
|
||||
}
|
||||
|
||||
let active = tracker.activeHeadphone
|
||||
// Find best active device (either marked active or any connected device with battery data)
|
||||
let active = tracker.activeHeadphone ?? tracker.devices.first(where: { $0.isConnected && $0.primaryBatteryPercent != nil })
|
||||
let isConn = active?.isConnected == true
|
||||
let percent = active?.primaryBatteryPercent
|
||||
|
||||
|
|
@ -95,7 +96,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
private func setupMenu() {
|
||||
let menu = NSMenu()
|
||||
|
||||
let active = tracker.activeHeadphone
|
||||
let active = tracker.activeHeadphone ?? tracker.devices.first(where: { $0.isConnected && $0.primaryBatteryPercent != nil })
|
||||
if let dev = active, dev.isConnected {
|
||||
let percentStr = dev.primaryBatteryPercent != nil ? "\(dev.primaryBatteryPercent!)%" : "Подключено"
|
||||
let titleItem = NSMenuItem(title: "🎧 \(dev.name): \(percentStr)", action: nil, keyEquivalent: "")
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||
APP_NAME="BLTS Tracker.app"
|
||||
SOURCE_APP="$DIR/$APP_NAME"
|
||||
|
||||
echo "🛑 Завершение запущенных копий..."
|
||||
killall blts_tracker 2>/dev/null || true
|
||||
echo "🛑 Завершение всех запущенных копий..."
|
||||
killall -9 blts_tracker 2>/dev/null || true
|
||||
pkill -9 -f "BLTS Tracker" 2>/dev/null || true
|
||||
pkill -9 -f "blts_tracker" 2>/dev/null || true
|
||||
sleep 1
|
||||
|
||||
echo "🔨 Сборка приложения..."
|
||||
|
|
@ -29,4 +31,4 @@ osascript -e "tell application \"System Events\" to make login item at end with
|
|||
echo "🚀 Запуск $TARGET_APP..."
|
||||
open "$TARGET_APP"
|
||||
|
||||
echo "✅ Готово! BLTS Tracker обновлен."
|
||||
echo "✅ Готово! BLTS Tracker обновлен и запущен."
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue