diff --git a/src/i18n/MControlCenter_de_DE.ts b/src/i18n/MControlCenter_de_DE.ts index 5cee723..bad4b41 100644 --- a/src/i18n/MControlCenter_de_DE.ts +++ b/src/i18n/MControlCenter_de_DE.ts @@ -155,6 +155,16 @@ Advanced Erweitert + + Couldn't connect to UPower to get charger status. +Make sure that UPower is installed and running then restart the system. + + + + Couldn't connect to a power profile service. +Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system. + + Cooling Kühlen @@ -215,6 +225,22 @@ Current fan Mode: Aktueller Lüftermodus: + + Follow system's power profile + + + + Automatic Profile Switching + + + + On Charger: + + + + On Battery: + + Keyboard Tastatur diff --git a/src/i18n/MControlCenter_en.ts b/src/i18n/MControlCenter_en.ts index b587b6a..bde91f9 100644 --- a/src/i18n/MControlCenter_en.ts +++ b/src/i18n/MControlCenter_en.ts @@ -115,16 +115,6 @@ rpm - - Couldn't connect to UPower to get charger status. -Make sure that UPower is installed and running then restart the app. - - - - Couldn't connect to Power Profiles Daemon. -Make sure that either Power Profiles Daemon or TuneD is installed and restart the app. - - Mode @@ -165,6 +155,16 @@ Make sure that either Power Profiles Daemon or TuneD is installed and restart th Advanced + + Couldn't connect to UPower to get charger status. +Make sure that UPower is installed and running then restart the system. + + + + Couldn't connect to a power profile service. +Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system. + + Cooling diff --git a/src/i18n/MControlCenter_es.ts b/src/i18n/MControlCenter_es.ts index 837019c..278ead4 100644 --- a/src/i18n/MControlCenter_es.ts +++ b/src/i18n/MControlCenter_es.ts @@ -155,6 +155,16 @@ Advanced Avanzado + + Couldn't connect to UPower to get charger status. +Make sure that UPower is installed and running then restart the system. + + + + Couldn't connect to a power profile service. +Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system. + + Cooling Enfriamiento @@ -243,10 +253,26 @@ Maximum performance at the cost of heat and increased power consumption + + Follow system's power profile + + If you mainly use your laptop with the charger plugged most of the time, it is recommended to set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle. + + Automatic Profile Switching + + + + On Charger: + + + + On Battery: + + Charge the battery when under 90%, stop at 100% diff --git a/src/i18n/MControlCenter_eu.ts b/src/i18n/MControlCenter_eu.ts index 6c78502..ce2d171 100644 --- a/src/i18n/MControlCenter_eu.ts +++ b/src/i18n/MControlCenter_eu.ts @@ -155,6 +155,16 @@ Advanced Aurreratua + + Couldn't connect to UPower to get charger status. +Make sure that UPower is installed and running then restart the system. + + + + Couldn't connect to a power profile service. +Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system. + + Cooling Hoztu @@ -243,10 +253,26 @@ Maximum performance at the cost of heat and increased power consumption + + Follow system's power profile + + If you mainly use your laptop with the charger plugged most of the time, it is recommended to set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle. + + Automatic Profile Switching + + + + On Charger: + + + + On Battery: + + Charge the battery when under 90%, stop at 100% diff --git a/src/i18n/MControlCenter_fi_FI.ts b/src/i18n/MControlCenter_fi_FI.ts index 3fb0ae4..65f5ba3 100644 --- a/src/i18n/MControlCenter_fi_FI.ts +++ b/src/i18n/MControlCenter_fi_FI.ts @@ -155,6 +155,16 @@ Advanced Edistynyt + + Couldn't connect to UPower to get charger status. +Make sure that UPower is installed and running then restart the system. + + + + Couldn't connect to a power profile service. +Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system. + + Cooling Jäähdytys @@ -243,10 +253,26 @@ Maximum performance at the cost of heat and increased power consumption + + Follow system's power profile + + If you mainly use your laptop with the charger plugged most of the time, it is recommended to set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle. + + Automatic Profile Switching + + + + On Charger: + + + + On Battery: + + Charge the battery when under 90%, stop at 100% diff --git a/src/i18n/MControlCenter_fr.ts b/src/i18n/MControlCenter_fr.ts index 06e97a7..311539a 100644 --- a/src/i18n/MControlCenter_fr.ts +++ b/src/i18n/MControlCenter_fr.ts @@ -155,6 +155,16 @@ Advanced Avancé + + Couldn't connect to UPower to get charger status. +Make sure that UPower is installed and running then restart the system. + + + + Couldn't connect to a power profile service. +Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system. + + Cooling Refroidissement @@ -243,10 +253,26 @@ Maximum performance at the cost of heat and increased power consumption Performances maximales au prix de la chaleur et d'une consommation électrique accrue + + Follow system's power profile + + If you mainly use your laptop with the charger plugged most of the time, it is recommended to set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle. Si vous utilisez principalement votre ordinateur avec le chargeur branché, il est recommandé de mettre la limite de charge à un pourcentage plus bas (60 % ou 80 %) pour prolonger la durée de vie de votre batterie. + + Automatic Profile Switching + + + + On Charger: + + + + On Battery: + + Charge the battery when under 90%, stop at 100% Charge la batterie en-dessous de 90 %, arrête à 100 % diff --git a/src/i18n/MControlCenter_hu.ts b/src/i18n/MControlCenter_hu.ts index e716cd1..f5f4652 100644 --- a/src/i18n/MControlCenter_hu.ts +++ b/src/i18n/MControlCenter_hu.ts @@ -155,6 +155,16 @@ Advanced Haladó + + Couldn't connect to UPower to get charger status. +Make sure that UPower is installed and running then restart the system. + + + + Couldn't connect to a power profile service. +Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system. + + Cooling Hűtés @@ -243,10 +253,26 @@ Maximum performance at the cost of heat and increased power consumption + + Follow system's power profile + + If you mainly use your laptop with the charger plugged most of the time, it is recommended to set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle. + + Automatic Profile Switching + + + + On Charger: + + + + On Battery: + + Charge the battery when under 90%, stop at 100% diff --git a/src/i18n/MControlCenter_it.ts b/src/i18n/MControlCenter_it.ts index eabe890..23216da 100644 --- a/src/i18n/MControlCenter_it.ts +++ b/src/i18n/MControlCenter_it.ts @@ -155,6 +155,16 @@ Advanced Avanzato + + Couldn't connect to UPower to get charger status. +Make sure that UPower is installed and running then restart the system. + + + + Couldn't connect to a power profile service. +Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system. + + Cooling Raffreddamento @@ -243,10 +253,26 @@ Maximum performance at the cost of heat and increased power consumption + + Follow system's power profile + + If you mainly use your laptop with the charger plugged most of the time, it is recommended to set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle. + + Automatic Profile Switching + + + + On Charger: + + + + On Battery: + + Charge the battery when under 90%, stop at 100% diff --git a/src/i18n/MControlCenter_nb.ts b/src/i18n/MControlCenter_nb.ts index 7328bc3..64c5f25 100644 --- a/src/i18n/MControlCenter_nb.ts +++ b/src/i18n/MControlCenter_nb.ts @@ -155,6 +155,16 @@ Advanced Avansert + + Couldn't connect to UPower to get charger status. +Make sure that UPower is installed and running then restart the system. + + + + Couldn't connect to a power profile service. +Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system. + + Cooling Kjøling @@ -243,10 +253,26 @@ Maximum performance at the cost of heat and increased power consumption + + Follow system's power profile + + If you mainly use your laptop with the charger plugged most of the time, it is recommended to set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle. + + Automatic Profile Switching + + + + On Charger: + + + + On Battery: + + Charge the battery when under 90%, stop at 100% diff --git a/src/i18n/MControlCenter_nl_NL.ts b/src/i18n/MControlCenter_nl_NL.ts index 8179d4e..a6cf85e 100644 --- a/src/i18n/MControlCenter_nl_NL.ts +++ b/src/i18n/MControlCenter_nl_NL.ts @@ -155,6 +155,16 @@ Advanced Geavanceerd + + Couldn't connect to UPower to get charger status. +Make sure that UPower is installed and running then restart the system. + + + + Couldn't connect to a power profile service. +Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system. + + Cooling Koelen @@ -243,10 +253,26 @@ Maximum performance at the cost of heat and increased power consumption + + Follow system's power profile + + If you mainly use your laptop with the charger plugged most of the time, it is recommended to set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle. + + Automatic Profile Switching + + + + On Charger: + + + + On Battery: + + Charge the battery when under 90%, stop at 100% diff --git a/src/i18n/MControlCenter_pt_BR.ts b/src/i18n/MControlCenter_pt_BR.ts index 06e3b43..0d87bb8 100644 --- a/src/i18n/MControlCenter_pt_BR.ts +++ b/src/i18n/MControlCenter_pt_BR.ts @@ -155,6 +155,17 @@ Advanced Avançado + + Couldn't connect to UPower to get charger status. +Make sure that UPower is installed and running then restart the system. + + + + Couldn't connect to a power profile service. +Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system. + Não foi possível conectar a um serviço de perfil de energia. +Certifique-se de que o Power Profiles Daemon, TuneD ou system76-power está instalado e reinicie o sistema. + Cooling Arrefecimento @@ -243,10 +254,26 @@ Maximum performance at the cost of heat and increased power consumption + + Follow system's power profile + + If you mainly use your laptop with the charger plugged most of the time, it is recommended to set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle. + + Automatic Profile Switching + + + + On Charger: + + + + On Battery: + + Charge the battery when under 90%, stop at 100% diff --git a/src/i18n/MControlCenter_pt_PT.ts b/src/i18n/MControlCenter_pt_PT.ts index a67ea4f..a3c712d 100644 --- a/src/i18n/MControlCenter_pt_PT.ts +++ b/src/i18n/MControlCenter_pt_PT.ts @@ -155,6 +155,16 @@ Advanced Avançado + + Couldn't connect to UPower to get charger status. +Make sure that UPower is installed and running then restart the system. + + + + Couldn't connect to a power profile service. +Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system. + + Cooling Arrefecimento @@ -243,10 +253,26 @@ Maximum performance at the cost of heat and increased power consumption + + Follow system's power profile + + If you mainly use your laptop with the charger plugged most of the time, it is recommended to set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle. + + Automatic Profile Switching + + + + On Charger: + + + + On Battery: + + Charge the battery when under 90%, stop at 100% diff --git a/src/i18n/MControlCenter_ru.ts b/src/i18n/MControlCenter_ru.ts index 4687c68..35a4dfd 100644 --- a/src/i18n/MControlCenter_ru.ts +++ b/src/i18n/MControlCenter_ru.ts @@ -155,6 +155,16 @@ Advanced Расширенный + + Couldn't connect to UPower to get charger status. +Make sure that UPower is installed and running then restart the system. + + + + Couldn't connect to a power profile service. +Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system. + + Cooling Охлаждение @@ -215,6 +225,22 @@ Current fan Mode: Режим вентилятора: + + Follow system's power profile + + + + Automatic Profile Switching + + + + On Charger: + + + + On Battery: + + Keyboard Клавиатура diff --git a/src/i18n/MControlCenter_tr.ts b/src/i18n/MControlCenter_tr.ts index 3875893..83e59a4 100644 --- a/src/i18n/MControlCenter_tr.ts +++ b/src/i18n/MControlCenter_tr.ts @@ -158,6 +158,16 @@ Advanced + + Couldn't connect to UPower to get charger status. +Make sure that UPower is installed and running then restart the system. + + + + Couldn't connect to a power profile service. +Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system. + + Cooling @@ -246,10 +256,26 @@ Maximum performance at the cost of heat and increased power consumption + + Follow system's power profile + + If you mainly use your laptop with the charger plugged most of the time, it is recommended to set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle. + + Automatic Profile Switching + + + + On Charger: + + + + On Battery: + + Charge the battery when under 90%, stop at 100% diff --git a/src/i18n/MControlCenter_vi.ts b/src/i18n/MControlCenter_vi.ts index 19ad302..6353a0b 100644 --- a/src/i18n/MControlCenter_vi.ts +++ b/src/i18n/MControlCenter_vi.ts @@ -155,6 +155,16 @@ Advanced Nâng cao + + Couldn't connect to UPower to get charger status. +Make sure that UPower is installed and running then restart the system. + + + + Couldn't connect to a power profile service. +Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system. + + Cooling Tản nhiệt @@ -243,10 +253,26 @@ Maximum performance at the cost of heat and increased power consumption + + Follow system's power profile + + If you mainly use your laptop with the charger plugged most of the time, it is recommended to set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle. + + Automatic Profile Switching + + + + On Charger: + + + + On Battery: + + Charge the battery when under 90%, stop at 100% diff --git a/src/i18n/MControlCenter_zh_CN.ts b/src/i18n/MControlCenter_zh_CN.ts index 86f1ca5..ead600a 100644 --- a/src/i18n/MControlCenter_zh_CN.ts +++ b/src/i18n/MControlCenter_zh_CN.ts @@ -155,6 +155,16 @@ Advanced 高级(手动) + + Couldn't connect to UPower to get charger status. +Make sure that UPower is installed and running then restart the system. + + + + Couldn't connect to a power profile service. +Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system. + + Cooling 冷却选项 @@ -243,10 +253,26 @@ Maximum performance at the cost of heat and increased power consumption + + Follow system's power profile + + If you mainly use your laptop with the charger plugged most of the time, it is recommended to set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle. + + Automatic Profile Switching + + + + On Charger: + + + + On Battery: + + Charge the battery when under 90%, stop at 100% diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c5f29ba..9866ef3 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -843,6 +843,7 @@ void MainWindow::on_autoAcDcProfilesGroupBox_toggled(bool checked) { } powerMonitor.disconnectFromPowerProfiles(); + powerMonitor.disconnectFromSystem76Power(); ui->autoPPDCheckBox->setChecked(0); ui->autoPPDCheckBox->setEnabled(0); powerMonitor.queryChargerState(); @@ -856,10 +857,13 @@ void MainWindow::on_autoAcDcProfilesGroupBox_toggled(bool checked) { void MainWindow::on_autoPPDCheckBox_toggled(bool checked) { if (checked) { - - if (!powerMonitor.connectToPowerProfiles()) { - QMessageBox::critical(nullptr, this->windowTitle(), tr("Couldn't connect to Power Profiles Daemon.\n" - "Make sure that either Power Profiles Daemon or TuneD is installed and restart the system.")); + if (powerMonitor.connectToSystem76Power()) { + powerMonitor.querySystem76Profile(); + } else if (powerMonitor.connectToPowerProfiles()) { + powerMonitor.queryPowerProfile(); + } else { + QMessageBox::critical(nullptr, this->windowTitle(), tr("Couldn't connect to a power profile service.\n" + "Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system.")); ui->autoPPDCheckBox->setChecked(0); return; } @@ -871,13 +875,14 @@ void MainWindow::on_autoPPDCheckBox_toggled(bool checked) { ui->superBatteryModeRadioButton->setEnabled(0); ui->autoAcDcProfilesGroupBox->setChecked(0); ui->autoAcDcProfilesGroupBox->setEnabled(0); - powerMonitor.queryPowerProfile(); } else { ui->highPerformanceModeRadioButton->setEnabled(1); ui->balancedModeRadioButton->setEnabled(1); ui->silentModeRadioButton->setEnabled(1); ui->superBatteryModeRadioButton->setEnabled(1); ui->autoAcDcProfilesGroupBox->setEnabled(1); + powerMonitor.disconnectFromPowerProfiles(); + powerMonitor.disconnectFromSystem76Power(); } Settings::setValue("Settings/autoPPDstate", checked); } diff --git a/src/powermonitor.cpp b/src/powermonitor.cpp index 81e90f2..dd88308 100644 --- a/src/powermonitor.cpp +++ b/src/powermonitor.cpp @@ -205,3 +205,78 @@ PowerProfile PowerMonitor::parsePowerProfile(const QString &profile) { return PowerProfile::PowerSaver; return PowerProfile::Unknown; } + +bool PowerMonitor::connectToSystem76Power() { + if(isSystem76Connected) { + return true; + } + + auto bus = QDBusConnection::systemBus(); + + if (!bus.interface()->isServiceRegistered("com.system76.PowerDaemon")) { + return false; + } + + bool ok = bus.connect( + "com.system76.PowerDaemon", + "/com/system76/PowerDaemon", + "com.system76.PowerDaemon", + "PowerProfileSwitch", + this, + SLOT(onSystem76ProfileChanged(QString)) + ); + + isSystem76Connected = ok; + return ok; +} + +void PowerMonitor::disconnectFromSystem76Power() { + if (isSystem76Connected) { + QDBusConnection::systemBus().disconnect( + "com.system76.PowerDaemon", + "/com/system76/PowerDaemon", + "com.system76.PowerDaemon", + "PowerProfileSwitch", + this, + SLOT(onSystem76ProfileChanged(QString)) + ); + isSystem76Connected = false; + } +} + +void PowerMonitor::querySystem76Profile() { + if (isSystem76Connected) { + QDBusInterface iface( + "com.system76.PowerDaemon", + "/com/system76/PowerDaemon", + "com.system76.PowerDaemon", + QDBusConnection::systemBus() + ); + + QDBusReply reply = iface.call("GetProfile"); + + if (!reply.isValid()) { + return; + } + + const QString profileName = reply.value(); + + PowerProfile profile = parseSystem76Profile(profileName); + + emit currentPowerProfile(profile); + } +} + +void PowerMonitor::onSystem76ProfileChanged(const QString &profile) { + emit currentPowerProfile(parseSystem76Profile(profile)); +} + +PowerProfile PowerMonitor::parseSystem76Profile(const QString &profile) { + if (profile == "Performance") + return PowerProfile::Performance; + if (profile == "Balanced") + return PowerProfile::Balanced; + if (profile == "Battery") + return PowerProfile::PowerSaver; + return PowerProfile::Unknown; +} diff --git a/src/powermonitor.h b/src/powermonitor.h index 01f16cc..ab0c85c 100644 --- a/src/powermonitor.h +++ b/src/powermonitor.h @@ -36,19 +36,24 @@ class PowerMonitor : public QObject { bool connectToUpower(); bool connectToPowerProfiles(); + bool connectToSystem76Power(); void disconnectFromUpower(); void disconnectFromPowerProfiles(); + void disconnectFromSystem76Power(); void queryChargerState(); void queryPowerProfile(); + void querySystem76Profile(); Q_ENUM(PowerProfile) private: bool parseChargerState(uint state) const; PowerProfile parsePowerProfile(const QString &profile); + PowerProfile parseSystem76Profile(const QString &profile); bool isUPowerConnected = false; bool isPowerProfileConnected = false; + bool isSystem76Connected = false; signals: void currentChargerState(bool isOnline); @@ -62,6 +67,8 @@ private slots: void onPowerProfileChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalidatedProps); + + void onSystem76ProfileChanged(const QString &profile); }; #endif // POWERMONITOR_H