Skip to content

Commit ed26c4f

Browse files
authored
Merge pull request #46 from tim-gromeyer/linux-airpods-battery-level
[Linux] Show correct battery level when 1 Airpod is disconnected
2 parents 5efbfa7 + 46d6cab commit ed26c4f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

linux/main.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,21 @@ public slots:
339339
QStringList parts = status.split(", ");
340340
int leftLevel = parts[0].split(": ")[1].replace("%", "").toInt();
341341
int rightLevel = parts[1].split(": ")[1].replace("%", "").toInt();
342-
int minLevel = qMin(leftLevel, rightLevel);
342+
343+
int minLevel;
344+
if (leftLevel == 0)
345+
{
346+
minLevel = rightLevel;
347+
}
348+
else if (rightLevel == 0)
349+
{
350+
minLevel = leftLevel;
351+
}
352+
else
353+
{
354+
minLevel = qMin(leftLevel, rightLevel);
355+
}
356+
343357

344358
QPixmap pixmap(32, 32);
345359
pixmap.fill(Qt::transparent);
@@ -952,4 +966,4 @@ int main(int argc, char *argv[]) {
952966
}
953967

954968

955-
#include "main.moc"
969+
#include "main.moc"

0 commit comments

Comments
 (0)