mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-01-29 22:30:57 +00:00
Compare commits
4 Commits
nightly
...
nightly-f5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7a96c9fc5 | ||
|
|
b732c66962 | ||
|
|
f5742618c7 | ||
|
|
802c2e0220 |
@@ -75,3 +75,5 @@ install(TARGETS librepods
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
install(FILES assets/me.kavishdevar.librepods.desktop
|
||||
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
|
||||
|
||||
@@ -8,7 +8,7 @@ ApplicationWindow {
|
||||
visible: !airPodsTrayApp.hideOnStart
|
||||
width: 400
|
||||
height: 300
|
||||
title: "Librepods"
|
||||
title: "LibrePods"
|
||||
objectName: "mainWindowObject"
|
||||
|
||||
onClosing: mainWindow.visible = false
|
||||
|
||||
9
linux/assets/me.kavishdevar.librepods.desktop
Normal file
9
linux/assets/me.kavishdevar.librepods.desktop
Normal file
@@ -0,0 +1,9 @@
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Application
|
||||
Name=LibrePods
|
||||
Comment=AirPods libreated from Apple's ecosystem
|
||||
Exec=librepods
|
||||
Icon=librepods
|
||||
Terminal=false
|
||||
Categories=Audio;AudioVideo;Utility;Qt;
|
||||
@@ -3,9 +3,9 @@
|
||||
#include <QDebug>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(Librepods)
|
||||
Q_DECLARE_LOGGING_CATEGORY(librepods)
|
||||
|
||||
#define LOG_INFO(msg) qCInfo(Librepods) << "\033[32m" << msg << "\033[0m"
|
||||
#define LOG_WARN(msg) qCWarning(Librepods) << "\033[33m" << msg << "\033[0m"
|
||||
#define LOG_ERROR(msg) qCCritical(Librepods) << "\033[31m" << msg << "\033[0m"
|
||||
#define LOG_DEBUG(msg) qCDebug(Librepods) << "\033[34m" << msg << "\033[0m"
|
||||
#define LOG_INFO(msg) qCInfo(librepods) << "\033[32m" << msg << "\033[0m"
|
||||
#define LOG_WARN(msg) qCWarning(librepods) << "\033[33m" << msg << "\033[0m"
|
||||
#define LOG_ERROR(msg) qCCritical(librepods) << "\033[31m" << msg << "\033[0m"
|
||||
#define LOG_DEBUG(msg) qCDebug(librepods) << "\033[34m" << msg << "\033[0m"
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
using namespace AirpodsTrayApp::Enums;
|
||||
|
||||
Q_LOGGING_CATEGORY(Librepods, "Librepods")
|
||||
Q_LOGGING_CATEGORY(librepods, "librepods")
|
||||
|
||||
class AirPodsTrayApp : public QObject {
|
||||
Q_OBJECT
|
||||
@@ -50,8 +50,8 @@ public:
|
||||
, m_deviceInfo(new DeviceInfo(this)), m_bleManager(new BleManager(this))
|
||||
, m_systemSleepMonitor(new SystemSleepMonitor(this))
|
||||
{
|
||||
QLoggingCategory::setFilterRules(QString("Librepods.debug=%1").arg(debugMode ? "true" : "false"));
|
||||
LOG_INFO("Initializing AirPodsTrayApp");
|
||||
QLoggingCategory::setFilterRules(QString("librepods.debug=%1").arg(debugMode ? "true" : "false"));
|
||||
LOG_INFO("Initializing LibrePods");
|
||||
|
||||
// Initialize tray icon and connect signals
|
||||
trayManager = new TrayIconManager(this);
|
||||
@@ -96,6 +96,15 @@ public:
|
||||
QBluetoothDeviceInfo device(address, "", 0);
|
||||
if (isAirPodsDevice(device)) {
|
||||
connectToDevice(device);
|
||||
|
||||
// On startup after reboot, activate A2DP profile for already connected AirPods
|
||||
QTimer::singleShot(2000, this, [this, address]()
|
||||
{
|
||||
QString formattedAddress = address.toString().replace(":", "_");
|
||||
mediaController->setConnectedDeviceMacAddress(formattedAddress);
|
||||
mediaController->activateA2dpProfile();
|
||||
LOG_INFO("A2DP profile activation attempted for AirPods found on startup");
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -397,6 +406,23 @@ public slots:
|
||||
{
|
||||
LOG_INFO("System is waking up, starting ble scan");
|
||||
m_bleManager->startScan();
|
||||
|
||||
// Check if AirPods are already connected and activate A2DP profile
|
||||
if (areAirpodsConnected() && m_deviceInfo && !m_deviceInfo->bluetoothAddress().isEmpty())
|
||||
{
|
||||
LOG_INFO("AirPods already connected after wake-up, re-activating A2DP profile");
|
||||
mediaController->setConnectedDeviceMacAddress(m_deviceInfo->bluetoothAddress().replace(":", "_"));
|
||||
|
||||
// Always activate A2DP profile after system wake since the profile might have been lost
|
||||
QTimer::singleShot(1000, this, [this]()
|
||||
{
|
||||
mediaController->activateA2dpProfile();
|
||||
LOG_INFO("A2DP profile activation attempted after system wake-up");
|
||||
});
|
||||
}
|
||||
|
||||
// Also check for already connected devices via BlueZ
|
||||
monitor->checkAlreadyConnectedDevices();
|
||||
}
|
||||
|
||||
private slots:
|
||||
@@ -445,6 +471,20 @@ private slots:
|
||||
{
|
||||
QBluetoothDeviceInfo device(QBluetoothAddress(address), name, 0);
|
||||
connectToDevice(device);
|
||||
|
||||
// After system reboot, AirPods might be connected but A2DP profile not active
|
||||
// Attempt to activate A2DP profile after a delay to ensure connection is established
|
||||
QTimer::singleShot(2000, this, [this, address]()
|
||||
{
|
||||
if (!address.isEmpty())
|
||||
{
|
||||
QString formattedAddress = address;
|
||||
formattedAddress = formattedAddress.replace(":", "_");
|
||||
mediaController->setConnectedDeviceMacAddress(formattedAddress);
|
||||
mediaController->activateA2dpProfile();
|
||||
LOG_INFO("A2DP profile activation attempted for newly connected device");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void onDeviceDisconnected(const QBluetoothAddress &address)
|
||||
@@ -951,6 +991,7 @@ int main(int argc, char *argv[]) {
|
||||
LOG_DEBUG("Socket error: " << socket.errorString());
|
||||
}
|
||||
}
|
||||
app.setDesktopFileName("me.kavishdevar.librepods");
|
||||
app.setQuitOnLastWindowClosed(false);
|
||||
|
||||
bool debugMode = false;
|
||||
|
||||
Reference in New Issue
Block a user