Skip to content
Draft
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@
*.exe
*.out
*.app

# Generated files
src/i18n/*
.cache/

# Generated build files
compile_commands.json
build/
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
120 changes: 120 additions & 0 deletions src/cli.cpp
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

#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");
}
}
34 changes: 34 additions & 0 deletions src/cli.h
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

#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
72 changes: 72 additions & 0 deletions src/i18n/MControlCenter_de_DE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,5 +297,77 @@ Weitere Informationen finden Sie auf der Seite &lt;Über&gt;.</translation>
<source>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.</source>
<translation>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.</translation>
</message>
<message>
<source>Fan 1:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Fan 2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Fan Mode:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Info</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Choose the mode that best suits your use case</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A mode that provides the best system performance for multi-tasking and heavy duty</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A mode that brings a balance between performance and battery live</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A quiet mode that lowers the fan noise</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A power-saving mode that lowers the power consumption for basic needs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>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</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Charge the battery to 100% all the time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Keyboard Backlit</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>FN ⇄ Super</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>USB Power Share</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GitHub:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bug tracker:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>An application that allows you to change the settings of MSI laptops running Linux</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
72 changes: 72 additions & 0 deletions src/i18n/MControlCenter_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,5 +296,77 @@ Check the &lt;About&gt; page for more info.</source>
<source>Failed to load both msi-ec/ec_sys</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Fan 1:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Fan 2:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Fan Mode:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Info</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Choose the mode that best suits your use case</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A mode that provides the best system performance for multi-tasking and heavy duty</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A mode that brings a balance between performance and battery live</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A quiet mode that lowers the fan noise</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>A power-saving mode that lowers the power consumption for basic needs</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>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</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Charge the battery to 100% all the time</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Keyboard Backlit</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>FN ⇄ Super</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>USB Power Share</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GitHub:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bug tracker:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>An application that allows you to change the settings of MSI laptops running Linux</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
Loading