diff --git a/.gitignore b/.gitignore
index 259148f..2048cee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,3 +30,11 @@
*.exe
*.out
*.app
+
+# Generated files
+src/i18n/*
+.cache/
+
+# Generated build files
+compile_commands.json
+build/
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ac961e2..f4c7289 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,9 +20,11 @@ set(PROJECT_SOURCES
src/mainwindow.ui
src/mainwindow.cpp src/mainwindow.h
src/operate.cpp src/operate.h
+ src/cli.cpp src/cli.h
src/helper.cpp src/helper.h
src/msi-ec_helper.cpp src/msi-ec_helper.h
src/settings.cpp src/settings.h
+ src/options.cpp src/options.h
src/resources.qrc
)
diff --git a/src/cli.cpp b/src/cli.cpp
new file mode 100644
index 0000000..32b2e06
--- /dev/null
+++ b/src/cli.cpp
@@ -0,0 +1,120 @@
+/* Copyright (C) 2022 Dmitry Serov
+ *
+ * This file is part of MControlCenter.
+ *
+ * MControlCenter is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * MControlCenter is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MControlCenter. If not, see .
+ */
+
+#include "cli.h"
+#include "operate.h"
+
+static Operate operate;
+
+CLI::CLI() {
+ if (!operate.isEcSysModuleLoaded() && !operate.loadEcSysModule()){
+ fprintf(stderr, "Failed to load the ec_sys kernel module\n");
+ exit(1);
+ }
+
+ if(!operate.updateEcData() || operate.getEcVersion().empty()){
+ fprintf(stderr, "Failed to update EC data\n");
+ exit(1);
+ }
+
+ if (!operate.doProbe()) {
+ fprintf(stderr, "Failed probing devices\n");
+ exit(1);
+ }
+}
+
+CLI::~CLI() {
+}
+
+void CLI::setCoolerBoost(Options::State state){
+ bool on = false;
+ if(state == Options::State::TOGGLE){ // TOGGLE
+ on = !operate.getCoolerBoostState();
+ }
+ else{
+ on = state;
+ }
+
+ if(operate.getCoolerBoostState() != on){
+ fprintf(stdout, "%s Cooler Boost\n", ( on ? "Enabling" : "Disabling" ));
+ operate.setCoolerBoostState(on);
+ if(!operate.updateEcData()) {
+ fprintf(stderr, "Failed to update EC data for Cooler Boost\n");
+ }
+ }
+}
+
+void CLI::changeUserMode(Options::Mode mode){
+ Options::Mode change_mode = mode;
+
+ if(mode == Options::Mode::NEXT){
+ user_mode cur_mode = operate.getUserMode();
+ switch (cur_mode) {
+ case user_mode::performance_mode:
+ change_mode = Options::Mode::BALANCED;
+ break;
+
+ case user_mode::balanced_mode:
+ change_mode = Options::Mode::SILENT;
+ break;
+
+ case user_mode::silent_mode:
+ change_mode = Options::Mode::BATTERY;
+ break;
+
+ case user_mode::super_battery_mode:
+ change_mode = Options::Mode::PERFORMANCE;
+ break;
+
+ case user_mode::unknown_mode:
+ change_mode = Options::Mode::PERFORMANCE;
+ fprintf(stderr, "Unknown User Mode detected\n");
+ }
+ }
+
+ user_mode user_mode = user_mode::performance_mode;
+ std::string text_mode;
+
+ switch (change_mode){
+ case Options::Mode::PERFORMANCE:
+ user_mode = user_mode::performance_mode;
+ text_mode = "Performance";
+ break;
+
+ case Options::Mode::BALANCED:
+ user_mode = user_mode::balanced_mode;
+ text_mode = "Balanced";
+ break;
+
+ case Options::Mode::SILENT:
+ user_mode = user_mode::silent_mode;
+ text_mode = "Silent";
+ break;
+
+ case Options::Mode::BATTERY:
+ user_mode = user_mode::super_battery_mode;
+ text_mode = "Super Battery";
+ break;
+ }
+
+ fprintf(stdout, "Changing User Mode to %s Mode\n", ( text_mode.c_str() ));
+ operate.setUserMode(user_mode);
+ if(!operate.updateEcData()) {
+ fprintf(stderr, "Failed to update EC data for User Mode\n");
+ }
+}
diff --git a/src/cli.h b/src/cli.h
new file mode 100644
index 0000000..b80b1e4
--- /dev/null
+++ b/src/cli.h
@@ -0,0 +1,34 @@
+/* Copyright (C) 2022 Dmitry Serov
+ *
+ * This file is part of MControlCenter.
+ *
+ * MControlCenter is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * MControlCenter is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MControlCenter. If not, see .
+ */
+
+#ifndef CLI_H
+#define CLI_H
+
+#include "options.h"
+
+class CLI {
+
+public:
+ CLI();
+ ~CLI();
+
+ void setCoolerBoost(Options::State state);
+ void changeUserMode(Options::Mode mode);
+};
+
+#endif // CLI_H
diff --git a/src/i18n/MControlCenter_de_DE.ts b/src/i18n/MControlCenter_de_DE.ts
index f14d7cd..e5cd9a5 100644
--- a/src/i18n/MControlCenter_de_DE.ts
+++ b/src/i18n/MControlCenter_de_DE.ts
@@ -297,5 +297,77 @@ Weitere Informationen finden Sie auf der Seite <Über>.
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.Wenn Sie Ihren Laptop überwiegend mit angeschlossenem Ladegerät verwenden, empfiehlt es sich, die Ladekapazität auf einen niedrigeren Prozentsatz (60 % oder 80 %) einzustellen, um die Lebensdauer Ihres Akkus zu verlängern.
+
+ Fan 1:
+
+
+
+ Fan 2:
+
+
+
+ Fan Mode:
+
+
+
+ Info
+
+
+
+ Choose the mode that best suits your use case
+
+
+
+ A mode that provides the best system performance for multi-tasking and heavy duty
+
+
+
+ A mode that brings a balance between performance and battery live
+
+
+
+ A quiet mode that lowers the fan noise
+
+
+
+ A power-saving mode that lowers the power consumption for basic needs
+
+
+
+ If you mainly use your laptop with adaptor plugged, we suggest you set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle
+
+
+
+ Charge the battery to 100% all the time
+
+
+
+ Keyboard Backlit
+
+
+
+ FN ⇄ Super
+
+
+
+ USB Power Share
+
+
+
+ Settings
+
+
+
+ GitHub:
+
+
+
+ Bug tracker:
+
+
+
+ An application that allows you to change the settings of MSI laptops running Linux
+
+
diff --git a/src/i18n/MControlCenter_en.ts b/src/i18n/MControlCenter_en.ts
index 6c95fa6..28e08c7 100644
--- a/src/i18n/MControlCenter_en.ts
+++ b/src/i18n/MControlCenter_en.ts
@@ -296,5 +296,77 @@ Check the <About> page for more info.
Failed to load both msi-ec/ec_sys
+
+ Fan 1:
+
+
+
+ Fan 2:
+
+
+
+ Fan Mode:
+
+
+
+ Info
+
+
+
+ Choose the mode that best suits your use case
+
+
+
+ A mode that provides the best system performance for multi-tasking and heavy duty
+
+
+
+ A mode that brings a balance between performance and battery live
+
+
+
+ A quiet mode that lowers the fan noise
+
+
+
+ A power-saving mode that lowers the power consumption for basic needs
+
+
+
+ If you mainly use your laptop with adaptor plugged, we suggest you set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle
+
+
+
+ Charge the battery to 100% all the time
+
+
+
+ Keyboard Backlit
+
+
+
+ FN ⇄ Super
+
+
+
+ USB Power Share
+
+
+
+ Settings
+
+
+
+ GitHub:
+
+
+
+ Bug tracker:
+
+
+
+ An application that allows you to change the settings of MSI laptops running Linux
+
+
diff --git a/src/i18n/MControlCenter_es.ts b/src/i18n/MControlCenter_es.ts
index 7a96233..b23c17d 100644
--- a/src/i18n/MControlCenter_es.ts
+++ b/src/i18n/MControlCenter_es.ts
@@ -249,7 +249,7 @@
Charge the battery when under 90%, stop at 100%
-
+ Carga la batería cuando esta por debajo del 50% hasta llegar al 60% {90%?} {100%?}Keyboard Backlight
@@ -296,5 +296,77 @@ Check the <About> page for more info.
Failed to load both msi-ec/ec_sys
+
+ Fan 1:
+
+
+
+ Fan 2:
+
+
+
+ Fan Mode:
+
+
+
+ Info
+
+
+
+ Choose the mode that best suits your use case
+
+
+
+ A mode that provides the best system performance for multi-tasking and heavy duty
+
+
+
+ A mode that brings a balance between performance and battery live
+
+
+
+ A quiet mode that lowers the fan noise
+
+
+
+ A power-saving mode that lowers the power consumption for basic needs
+
+
+
+ If you mainly use your laptop with adaptor plugged, we suggest you set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle
+
+
+
+ Charge the battery to 100% all the time
+
+
+
+ Keyboard Backlit
+
+
+
+ FN ⇄ Super
+
+
+
+ USB Power Share
+
+
+
+ Settings
+
+
+
+ GitHub:
+
+
+
+ Bug tracker:
+
+
+
+ An application that allows you to change the settings of MSI laptops running Linux
+
+
diff --git a/src/i18n/MControlCenter_eu.ts b/src/i18n/MControlCenter_eu.ts
index 081a1c3..3dbc381 100644
--- a/src/i18n/MControlCenter_eu.ts
+++ b/src/i18n/MControlCenter_eu.ts
@@ -249,7 +249,7 @@
Charge the battery when under 90%, stop at 100%
-
+ Kargatu bateria %50-tik behera dagoenean, %60-ra iristean gelditu {90%?} {100%?}Keyboard Backlight
@@ -296,5 +296,77 @@ Check the <About> page for more info.
Failed to load both msi-ec/ec_sys
+
+ Fan 1:
+
+
+
+ Fan 2:
+
+
+
+ Fan Mode:
+
+
+
+ Info
+
+
+
+ Choose the mode that best suits your use case
+
+
+
+ A mode that provides the best system performance for multi-tasking and heavy duty
+
+
+
+ A mode that brings a balance between performance and battery live
+
+
+
+ A quiet mode that lowers the fan noise
+
+
+
+ A power-saving mode that lowers the power consumption for basic needs
+
+
+
+ If you mainly use your laptop with adaptor plugged, we suggest you set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle
+
+
+
+ Charge the battery to 100% all the time
+
+
+
+ Keyboard Backlit
+
+
+
+ FN ⇄ Super
+
+
+
+ USB Power Share
+
+
+
+ Settings
+
+
+
+ GitHub:
+
+
+
+ Bug tracker:
+
+
+
+ An application that allows you to change the settings of MSI laptops running Linux
+
+
diff --git a/src/i18n/MControlCenter_fi_FI.ts b/src/i18n/MControlCenter_fi_FI.ts
index fe92032..07f0c5e 100644
--- a/src/i18n/MControlCenter_fi_FI.ts
+++ b/src/i18n/MControlCenter_fi_FI.ts
@@ -249,7 +249,7 @@
Charge the battery when under 90%, stop at 100%
-
+ Lataa akkua kun varaustaso on alle 50, lopeta lataaminen 60% {90%?} {100%?}Keyboard Backlight
@@ -296,5 +296,77 @@ Check the <About> page for more info.
Failed to load both msi-ec/ec_sys
+
+ Fan 1:
+
+
+
+ Fan 2:
+
+
+
+ Fan Mode:
+
+
+
+ Info
+
+
+
+ Choose the mode that best suits your use case
+
+
+
+ A mode that provides the best system performance for multi-tasking and heavy duty
+
+
+
+ A mode that brings a balance between performance and battery live
+
+
+
+ A quiet mode that lowers the fan noise
+
+
+
+ A power-saving mode that lowers the power consumption for basic needs
+
+
+
+ If you mainly use your laptop with adaptor plugged, we suggest you set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle
+
+
+
+ Charge the battery to 100% all the time
+
+
+
+ Keyboard Backlit
+
+
+
+ FN ⇄ Super
+
+
+
+ USB Power Share
+
+
+
+ Settings
+
+
+
+ GitHub:
+
+
+
+ Bug tracker:
+
+
+
+ An application that allows you to change the settings of MSI laptops running Linux
+
+
diff --git a/src/i18n/MControlCenter_fr.ts b/src/i18n/MControlCenter_fr.ts
index d9c6c0a..9eb6318 100644
--- a/src/i18n/MControlCenter_fr.ts
+++ b/src/i18n/MControlCenter_fr.ts
@@ -297,5 +297,77 @@ Regardez la page <À propos> pour plus d'informations.
Failed to load both msi-ec/ec_sysImpossible de détecter msi-ec ou ec_sys
+
+ Fan 1:
+
+
+
+ Fan 2:
+
+
+
+ Fan Mode:
+
+
+
+ Info
+
+
+
+ Choose the mode that best suits your use case
+
+
+
+ A mode that provides the best system performance for multi-tasking and heavy duty
+
+
+
+ A mode that brings a balance between performance and battery live
+
+
+
+ A quiet mode that lowers the fan noise
+
+
+
+ A power-saving mode that lowers the power consumption for basic needs
+
+
+
+ If you mainly use your laptop with adaptor plugged, we suggest you set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle
+
+
+
+ Charge the battery to 100% all the time
+
+
+
+ Keyboard Backlit
+
+
+
+ FN ⇄ Super
+
+
+
+ USB Power Share
+
+
+
+ Settings
+
+
+
+ GitHub:
+
+
+
+ Bug tracker:
+
+
+
+ An application that allows you to change the settings of MSI laptops running Linux
+
+
diff --git a/src/i18n/MControlCenter_hu.ts b/src/i18n/MControlCenter_hu.ts
index b51c11a..840e725 100644
--- a/src/i18n/MControlCenter_hu.ts
+++ b/src/i18n/MControlCenter_hu.ts
@@ -249,7 +249,7 @@
Charge the battery when under 90%, stop at 100%
-
+ Töltse fel az akkumulátort ha 50% alatt van és állítsa le a töltést 60%-on {90%?} {100%?}Keyboard Backlight
@@ -296,5 +296,77 @@ Check the <About> page for more info.
Failed to load both msi-ec/ec_sys
+
+ Fan 1:
+
+
+
+ Fan 2:
+
+
+
+ Fan Mode:
+
+
+
+ Info
+
+
+
+ Choose the mode that best suits your use case
+
+
+
+ A mode that provides the best system performance for multi-tasking and heavy duty
+
+
+
+ A mode that brings a balance between performance and battery live
+
+
+
+ A quiet mode that lowers the fan noise
+
+
+
+ A power-saving mode that lowers the power consumption for basic needs
+
+
+
+ If you mainly use your laptop with adaptor plugged, we suggest you set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle
+
+
+
+ Charge the battery to 100% all the time
+
+
+
+ Keyboard Backlit
+
+
+
+ FN ⇄ Super
+
+
+
+ USB Power Share
+
+
+
+ Settings
+
+
+
+ GitHub:
+
+
+
+ Bug tracker:
+
+
+
+ An application that allows you to change the settings of MSI laptops running Linux
+
+
diff --git a/src/i18n/MControlCenter_it.ts b/src/i18n/MControlCenter_it.ts
index 497f65c..956d429 100644
--- a/src/i18n/MControlCenter_it.ts
+++ b/src/i18n/MControlCenter_it.ts
@@ -249,7 +249,7 @@
Charge the battery when under 90%, stop at 100%
-
+ Carica la batteria quando sotto 50%, ferma al 60% {90%?} {100%?}Keyboard Backlight
@@ -296,5 +296,77 @@ Check the <About> page for more info.
Failed to load both msi-ec/ec_sys
+
+ Fan 1:
+
+
+
+ Fan 2:
+
+
+
+ Fan Mode:
+
+
+
+ Info
+
+
+
+ Choose the mode that best suits your use case
+
+
+
+ A mode that provides the best system performance for multi-tasking and heavy duty
+
+
+
+ A mode that brings a balance between performance and battery live
+
+
+
+ A quiet mode that lowers the fan noise
+
+
+
+ A power-saving mode that lowers the power consumption for basic needs
+
+
+
+ If you mainly use your laptop with adaptor plugged, we suggest you set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle
+
+
+
+ Charge the battery to 100% all the time
+
+
+
+ Keyboard Backlit
+
+
+
+ FN ⇄ Super
+
+
+
+ USB Power Share
+
+
+
+ Settings
+
+
+
+ GitHub:
+
+
+
+ Bug tracker:
+
+
+
+ An application that allows you to change the settings of MSI laptops running Linux
+
+
diff --git a/src/i18n/MControlCenter_nb.ts b/src/i18n/MControlCenter_nb.ts
index 973c679..608e4ef 100644
--- a/src/i18n/MControlCenter_nb.ts
+++ b/src/i18n/MControlCenter_nb.ts
@@ -249,7 +249,7 @@
Charge the battery when under 90%, stop at 100%
-
+ Lad batteriet når under 50%, stopp ved 60% {90%?} {100%?}Keyboard Backlight
@@ -296,5 +296,77 @@ Check the <About> page for more info.
Failed to load both msi-ec/ec_sys
+
+ Fan 1:
+
+
+
+ Fan 2:
+
+
+
+ Fan Mode:
+
+
+
+ Info
+
+
+
+ Choose the mode that best suits your use case
+
+
+
+ A mode that provides the best system performance for multi-tasking and heavy duty
+
+
+
+ A mode that brings a balance between performance and battery live
+
+
+
+ A quiet mode that lowers the fan noise
+
+
+
+ A power-saving mode that lowers the power consumption for basic needs
+
+
+
+ If you mainly use your laptop with adaptor plugged, we suggest you set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle
+
+
+
+ Charge the battery to 100% all the time
+
+
+
+ Keyboard Backlit
+
+
+
+ FN ⇄ Super
+
+
+
+ USB Power Share
+
+
+
+ Settings
+
+
+
+ GitHub:
+
+
+
+ Bug tracker:
+
+
+
+ An application that allows you to change the settings of MSI laptops running Linux
+
+
diff --git a/src/i18n/MControlCenter_nl_NL.ts b/src/i18n/MControlCenter_nl_NL.ts
index 19e2df6..a7b1cf6 100644
--- a/src/i18n/MControlCenter_nl_NL.ts
+++ b/src/i18n/MControlCenter_nl_NL.ts
@@ -249,7 +249,7 @@
Charge the battery when under 90%, stop at 100%
-
+ Laad de accu wanneer deze onder de 50% is, stop bij 60% {90%?} {100%?}Keyboard Backlight
@@ -296,5 +296,77 @@ Check the <About> page for more info.
Failed to load both msi-ec/ec_sys
+
+ Fan 1:
+
+
+
+ Fan 2:
+
+
+
+ Fan Mode:
+
+
+
+ Info
+
+
+
+ Choose the mode that best suits your use case
+
+
+
+ A mode that provides the best system performance for multi-tasking and heavy duty
+
+
+
+ A mode that brings a balance between performance and battery live
+
+
+
+ A quiet mode that lowers the fan noise
+
+
+
+ A power-saving mode that lowers the power consumption for basic needs
+
+
+
+ If you mainly use your laptop with adaptor plugged, we suggest you set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle
+
+
+
+ Charge the battery to 100% all the time
+
+
+
+ Keyboard Backlit
+
+
+
+ FN ⇄ Super
+
+
+
+ USB Power Share
+
+
+
+ Settings
+
+
+
+ GitHub:
+
+
+
+ Bug tracker:
+
+
+
+ An application that allows you to change the settings of MSI laptops running Linux
+
+
diff --git a/src/i18n/MControlCenter_pt_BR.ts b/src/i18n/MControlCenter_pt_BR.ts
index 62bbc3d..101c6ae 100644
--- a/src/i18n/MControlCenter_pt_BR.ts
+++ b/src/i18n/MControlCenter_pt_BR.ts
@@ -249,7 +249,7 @@
Charge the battery when under 90%, stop at 100%
-
+ Carregar a bateria quando estiver abaixo de 50%, parar a 60% {90%?} {100%?}Keyboard Backlight
@@ -296,5 +296,77 @@ Check the <About> page for more info.
Failed to load both msi-ec/ec_sys
+
+ Fan 1:
+
+
+
+ Fan 2:
+
+
+
+ Fan Mode:
+
+
+
+ Info
+
+
+
+ Choose the mode that best suits your use case
+
+
+
+ A mode that provides the best system performance for multi-tasking and heavy duty
+
+
+
+ A mode that brings a balance between performance and battery live
+
+
+
+ A quiet mode that lowers the fan noise
+
+
+
+ A power-saving mode that lowers the power consumption for basic needs
+
+
+
+ If you mainly use your laptop with adaptor plugged, we suggest you set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle
+
+
+
+ Charge the battery to 100% all the time
+
+
+
+ Keyboard Backlit
+
+
+
+ FN ⇄ Super
+
+
+
+ USB Power Share
+
+
+
+ Settings
+
+
+
+ GitHub:
+
+
+
+ Bug tracker:
+
+
+
+ An application that allows you to change the settings of MSI laptops running Linux
+
+
diff --git a/src/i18n/MControlCenter_pt_PT.ts b/src/i18n/MControlCenter_pt_PT.ts
index f11302c..58cdd48 100644
--- a/src/i18n/MControlCenter_pt_PT.ts
+++ b/src/i18n/MControlCenter_pt_PT.ts
@@ -249,7 +249,7 @@
Charge the battery when under 90%, stop at 100%
-
+ Carregar a bateria quando estiver abaixo de 50%, parar a 60% {90%?} {100%?}Keyboard Backlight
@@ -296,5 +296,77 @@ Check the <About> page for more info.
Failed to load both msi-ec/ec_sys
+
+ Fan 1:
+
+
+
+ Fan 2:
+
+
+
+ Fan Mode:
+
+
+
+ Info
+
+
+
+ Choose the mode that best suits your use case
+
+
+
+ A mode that provides the best system performance for multi-tasking and heavy duty
+
+
+
+ A mode that brings a balance between performance and battery live
+
+
+
+ A quiet mode that lowers the fan noise
+
+
+
+ A power-saving mode that lowers the power consumption for basic needs
+
+
+
+ If you mainly use your laptop with adaptor plugged, we suggest you set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle
+
+
+
+ Charge the battery to 100% all the time
+
+
+
+ Keyboard Backlit
+
+
+
+ FN ⇄ Super
+
+
+
+ USB Power Share
+
+
+
+ Settings
+
+
+
+ GitHub:
+
+
+
+ Bug tracker:
+
+
+
+ An application that allows you to change the settings of MSI laptops running Linux
+
+
diff --git a/src/i18n/MControlCenter_ru.ts b/src/i18n/MControlCenter_ru.ts
index 13f8bb7..1820045 100644
--- a/src/i18n/MControlCenter_ru.ts
+++ b/src/i18n/MControlCenter_ru.ts
@@ -297,5 +297,77 @@ Check the <About> page for more info.
Failed to load both msi-ec/ec_sys
+
+ Fan 1:
+
+
+
+ Fan 2:
+
+
+
+ Fan Mode:
+
+
+
+ Info
+
+
+
+ Choose the mode that best suits your use case
+
+
+
+ A mode that provides the best system performance for multi-tasking and heavy duty
+
+
+
+ A mode that brings a balance between performance and battery live
+
+
+
+ A quiet mode that lowers the fan noise
+
+
+
+ A power-saving mode that lowers the power consumption for basic needs
+
+
+
+ If you mainly use your laptop with adaptor plugged, we suggest you set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle
+
+
+
+ Charge the battery to 100% all the time
+
+
+
+ Keyboard Backlit
+
+
+
+ FN ⇄ Super
+
+
+
+ USB Power Share
+
+
+
+ Settings
+
+
+
+ GitHub:
+
+
+
+ Bug tracker:
+
+
+
+ An application that allows you to change the settings of MSI laptops running Linux
+
+
diff --git a/src/i18n/MControlCenter_tr.ts b/src/i18n/MControlCenter_tr.ts
index 1dd5d81..d63aec4 100644
--- a/src/i18n/MControlCenter_tr.ts
+++ b/src/i18n/MControlCenter_tr.ts
@@ -252,7 +252,7 @@
Charge the battery when under 90%, stop at 100%
-
+ Pili %50'nin altındayken şarj et, %60'a ulaşınca dur {90%?} {100%?}Keyboard Backlight
@@ -299,5 +299,77 @@ Check the <About> page for more info.
Failed to load both msi-ec/ec_sys
+
+ Fan 1:
+
+
+
+ Fan 2:
+
+
+
+ Fan Mode:
+
+
+
+ Info
+
+
+
+ Choose the mode that best suits your use case
+
+
+
+ A mode that provides the best system performance for multi-tasking and heavy duty
+
+
+
+ A mode that brings a balance between performance and battery live
+
+
+
+ A quiet mode that lowers the fan noise
+
+
+
+ A power-saving mode that lowers the power consumption for basic needs
+
+
+
+ If you mainly use your laptop with adaptor plugged, we suggest you set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle
+
+
+
+ Charge the battery to 100% all the time
+
+
+
+ Keyboard Backlit
+
+
+
+ FN ⇄ Super
+
+
+
+ USB Power Share
+
+
+
+ Settings
+
+
+
+ GitHub:
+
+
+
+ Bug tracker:
+
+
+
+ An application that allows you to change the settings of MSI laptops running Linux
+
+
diff --git a/src/i18n/MControlCenter_vi.ts b/src/i18n/MControlCenter_vi.ts
index ba73685..40b2c25 100644
--- a/src/i18n/MControlCenter_vi.ts
+++ b/src/i18n/MControlCenter_vi.ts
@@ -249,7 +249,7 @@
Charge the battery when under 90%, stop at 100%
-
+ Sạc khi pin dưới 50%, dừng khi đạt 60% {90%?} {100%?}Keyboard Backlight
@@ -296,5 +296,77 @@ Check the <About> page for more info.
Failed to load both msi-ec/ec_sys
+
+ Fan 1:
+
+
+
+ Fan 2:
+
+
+
+ Fan Mode:
+
+
+
+ Info
+
+
+
+ Choose the mode that best suits your use case
+
+
+
+ A mode that provides the best system performance for multi-tasking and heavy duty
+
+
+
+ A mode that brings a balance between performance and battery live
+
+
+
+ A quiet mode that lowers the fan noise
+
+
+
+ A power-saving mode that lowers the power consumption for basic needs
+
+
+
+ If you mainly use your laptop with adaptor plugged, we suggest you set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle
+
+
+
+ Charge the battery to 100% all the time
+
+
+
+ Keyboard Backlit
+
+
+
+ FN ⇄ Super
+
+
+
+ USB Power Share
+
+
+
+ Settings
+
+
+
+ GitHub:
+
+
+
+ Bug tracker:
+
+
+
+ An application that allows you to change the settings of MSI laptops running Linux
+
+
diff --git a/src/i18n/MControlCenter_zh_CN.ts b/src/i18n/MControlCenter_zh_CN.ts
index 8f51274..b677369 100644
--- a/src/i18n/MControlCenter_zh_CN.ts
+++ b/src/i18n/MControlCenter_zh_CN.ts
@@ -249,7 +249,7 @@
Charge the battery when under 90%, stop at 100%
-
+ 电量低于 50% 开始充电,充至 60% 停止 {90%?} {100%?}Keyboard Backlight
@@ -296,5 +296,77 @@ Check the <About> page for more info.
Failed to load both msi-ec/ec_sys
+
+ Fan 1:
+
+
+
+ Fan 2:
+
+
+
+ Fan Mode:
+
+
+
+ Info
+
+
+
+ Choose the mode that best suits your use case
+
+
+
+ A mode that provides the best system performance for multi-tasking and heavy duty
+
+
+
+ A mode that brings a balance between performance and battery live
+
+
+
+ A quiet mode that lowers the fan noise
+
+
+
+ A power-saving mode that lowers the power consumption for basic needs
+
+
+
+ If you mainly use your laptop with adaptor plugged, we suggest you set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle
+
+
+
+ Charge the battery to 100% all the time
+
+
+
+ Keyboard Backlit
+
+
+
+ FN ⇄ Super
+
+
+
+ USB Power Share
+
+
+
+ Settings
+
+
+
+ GitHub:
+
+
+
+ Bug tracker:
+
+
+
+ An application that allows you to change the settings of MSI laptops running Linux
+
+
diff --git a/src/main.cpp b/src/main.cpp
index 04faa86..b5413cc 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -17,19 +17,46 @@
*/
#include "mainwindow.h"
+#include "cli.h"
+#include "options.h"
#include
#include
#include
#include
-
int main(int argc, char *argv[]) {
+
+ Options options;
+ options.process_args(argc, argv);
+
const QString serverName = "MControlCenter";
- auto *socket = new QLocalSocket();
+ QLocalSocket* socket = new QLocalSocket();
socket->connectToServer(serverName);
+
+ if(options.cli){
+ fprintf(stderr, "Executing CLI commands...\n");
+ CLI cli;
+ if(options.cooler_boost.has_value()){
+ cli.setCoolerBoost(options.cooler_boost.value());
+ }
+ if(options.user_mode.has_value()){
+ cli.changeUserMode(options.user_mode.value());
+ }
+
+ if (socket->isOpen()) {
+ socket->write("update");
+ socket->flush();
+ socket->close();
+ }
+ socket->deleteLater();
+ return 0;
+ }
+
if (socket->isOpen()) {
fprintf(stderr, "Another instance of the application is already running\n");
+ socket->write("show");
+ socket->flush();
socket->close();
socket->deleteLater();
return 0;
@@ -51,8 +78,17 @@ int main(int argc, char *argv[]) {
MainWindow w;
QLocalServer server;
- QObject::connect(&server, &QLocalServer::newConnection, [&w]() {
- w.show();
+ QObject::connect(&server, &QLocalServer::newConnection, [&w, &server]() {
+ QLocalSocket* socket = server.nextPendingConnection();
+ if(socket->waitForConnected() && socket->waitForReadyRead()){
+ QByteArray data = socket->readAll();
+ if(std::string(data.data()) == "show"){
+ w.show();
+ }
+ else if(std::string(data.data()) == "update"){
+ w.externalUpdate();
+ }
+ }
});
bool serverListening = server.listen(serverName);
if (!serverListening && (server.serverError() == QAbstractSocket::AddressInUseError)) {
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 5fbaf3d..2b023fc 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -23,7 +23,7 @@
#include
#include
-Operate operate;
+static Operate operate;
bool isActive = false;
bool isUpdateDataError = false;
@@ -215,6 +215,11 @@ void MainWindow::realtimeUpdate() {
updateData();
}
+void MainWindow::externalUpdate() {
+ if(operate.updateEcData())
+ updateData();
+}
+
void MainWindow::updateData() {
if (!isUpdateDataError && (operate.isMsiEcLoaded() || operate.isEcSysModuleLoaded())) {
if (!isActive) {
@@ -232,6 +237,7 @@ void MainWindow::updateData() {
updateFan2Speed();
updateKeyboardBrightness();
updateWebCamState();
+ updateCoolerBoostState();
if (operate.isMsiEcLoaded()) {
ui->MsiEcStatusLabel->setText(tr("Loaded"));
@@ -467,10 +473,10 @@ void MainWindow::updateFanMode() {
void MainWindow::updateFanSpeedSettings() {
ui->advancedFanControlCheckBox->setChecked(operate.getFanMode() == fan_mode::advanced_fan_mode);
- QVector fan1SpeedSettings = operate.getFan1SpeedSettings();
- QVector fan1TempSettings = operate.getFan1TempSettings();
- QVector fan2SpeedSettings = operate.getFan2SpeedSettings();
- QVector fan2TempSettings = operate.getFan2TempSettings();
+ QVector fan1SpeedSettings = operate.getFan1SpeedSettings();
+ QVector fan1TempSettings = operate.getFan1TempSettings();
+ QVector fan2SpeedSettings = operate.getFan2SpeedSettings();
+ QVector fan2TempSettings = operate.getFan2TempSettings();
ui->fan1Speed1Slider->setValue(fan1SpeedSettings[0]);
ui->fan1Speed2Slider->setValue(fan1SpeedSettings[1]);
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 7707139..17893a9 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -35,6 +35,7 @@ Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
+ void externalUpdate();
void updateData();
static void setUpdateDataError(bool error);
diff --git a/src/options.cpp b/src/options.cpp
new file mode 100644
index 0000000..6102753
--- /dev/null
+++ b/src/options.cpp
@@ -0,0 +1,115 @@
+/* Copyright (C) 2022 Dmitry Serov
+ *
+ * This file is part of MControlCenter.
+ *
+ * MControlCenter is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * MControlCenter is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MControlCenter. If not, see .
+ */
+#include "options.h"
+
+Options::Options()
+ :cli(false), cooler_boost(std::nullopt)
+{}
+
+void Options::print_help(std::string program_name)
+{
+ fprintf(stdout, R"(Description
+Syntax: %s [options]
+
+ -B, --coolerboost STATE toggle fan cooler boost
+ -M, --usermode MODE change user mode
+ -h show help
+
+Arguments:
+ STATE: can be 'ON', 'OFF' or 'TOGGLE'
+ MODE: can be 'PERFORMANCE', 'BALANCED', 'SILENT', 'BATTERY', 'NEXT'
+)", program_name.c_str());
+ exit(1);
+}
+
+void Options::process_args(int argc, char** argv)
+{
+ int option_index;
+ while (true)
+ {
+ const auto opt = getopt_long(argc, argv, short_opts.data(), long_opts, &option_index);
+
+ if (-1 == opt){
+ break;
+ }
+
+ switch (opt)
+ {
+ case 0:
+ cli = true;
+ // long option without short equivalent
+ break;
+
+ case 'B':
+ cli = true;
+
+ if(std::string(optarg) =="ON"){
+ cooler_boost = std::optional{Options::State::ON};
+ }
+ else if(std::string(optarg) == "OFF")
+ {
+ cooler_boost = std::optional{Options::State::OFF};
+ }
+ else if(std::string(optarg) == "TOGGLE")
+ {
+ cooler_boost = std::optional{Options::State::TOGGLE};
+ }
+ else{
+ fprintf(stderr, "Wrong TOGGLE value for coolerboost option.\n");
+ print_help(argv[0]);
+ }
+
+ break;
+
+ case 'M':
+ cli = true;
+
+ if(std::string(optarg) == "BALANCED"){
+ user_mode = std::optional{Options::Mode::BALANCED};
+ }
+ else if(std::string(optarg) == "PERFORMANCE")
+ {
+ user_mode = std::optional{Options::Mode::PERFORMANCE};
+ }
+ else if(std::string(optarg) == "SILENT")
+ {
+ user_mode = std::optional{Options::Mode::SILENT};
+ }
+ else if(std::string(optarg) == "BATTERY")
+ {
+ user_mode = std::optional{Options::Mode::BATTERY};
+ }
+ else if(std::string(optarg) == "NEXT")
+ {
+ user_mode = std::optional{Options::Mode::NEXT};
+ }
+ else{
+ fprintf(stderr, "Wrong MODE value for usermode option.\n");
+ print_help(argv[0]);
+ }
+
+ break;
+
+ case 'h': // -h or --help
+ case '?': // Unrecognized option
+ default:
+ print_help(argv[0]);
+ break;
+ }
+ }
+}
diff --git a/src/options.h b/src/options.h
new file mode 100644
index 0000000..aa3d723
--- /dev/null
+++ b/src/options.h
@@ -0,0 +1,63 @@
+/* Copyright (C) 2022 Dmitry Serov
+ *
+ * This file is part of MControlCenter.
+ *
+ * MControlCenter is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * MControlCenter is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MControlCenter. If not, see .
+ */
+
+#ifndef OPTIONS_H
+#define OPTIONS_H
+
+#include
+#include
+#include
+
+class Options{
+public:
+ Options();
+ ~Options() = default;
+
+ enum State {
+ OFF = 0,
+ ON = 1,
+ TOGGLE = 2
+ };
+
+ enum Mode {
+ PERFORMANCE = 0,
+ BALANCED = 1,
+ SILENT = 2,
+ BATTERY = 3,
+ NEXT = 4
+ };
+
+ bool cli;
+ std::optional cooler_boost;
+ std::optional user_mode;
+
+ void process_args(int argc, char** argv);
+
+private:
+ static constexpr std::string_view const short_opts = "B:M:h";
+ static constexpr option long_opts[] = {
+ {"coolerboost", required_argument, nullptr, 'B'},
+ {"usermode", required_argument, nullptr, 'M'},
+ {"help", no_argument, nullptr, 'h'},
+ {nullptr, no_argument, nullptr, 0}
+ };
+
+ void print_help(std::string program_name);
+};
+
+#endif // OPTIONS_H