diff --git a/ResourceManager.cpp b/ResourceManager.cpp index 5e97dff08..b5641fa0d 100644 --- a/ResourceManager.cpp +++ b/ResourceManager.cpp @@ -30,6 +30,10 @@ #include "filesystem.h" #include "StringUtils.h" +#ifdef __linux__ +#include +#endif + /*---------------------------------------------------------*\ | Translation Strings | \*---------------------------------------------------------*/ @@ -190,6 +194,29 @@ ResourceManager::ResourceManager() profile_manager = new ProfileManager(GetConfigurationDirectory()); server->SetProfileManager(profile_manager); rgb_controllers_sizes = profile_manager->LoadProfileToList("sizes", true); + + /*-----------------------------------------------------*\ + | If configured, lower process priority to potentially | + | reduce interference with other programs. Positive | + | nice values decrease priority on Linux and MacOS. | + \*-----------------------------------------------------*/ + json general_settings = settings_manager->GetSettings("General"); + bool low_priority = false; + + if(general_settings.contains("low_priority")) + { + low_priority = general_settings["low_priority"]; + } + + if(low_priority) + { +#if defined(__linux__) || defined(__APPLE__) + setpriority(PRIO_PROCESS, 0, 10); +#endif +#ifdef _WIN32 + SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS); +#endif + } } ResourceManager::~ResourceManager() diff --git a/qt/OpenRGBDialog/OpenRGBDialog.cpp b/qt/OpenRGBDialog/OpenRGBDialog.cpp index 923210d23..b6cad235f 100644 --- a/qt/OpenRGBDialog/OpenRGBDialog.cpp +++ b/qt/OpenRGBDialog/OpenRGBDialog.cpp @@ -37,15 +37,10 @@ #include #include -#ifdef __linux__ -#include -#endif - #ifdef __APPLE__ #include "macutils.h" #endif - static int GetIcon(device_type type) { /*-----------------------------------------------------*\ @@ -193,18 +188,6 @@ OpenRGBDialog::OpenRGBDialog(QWidget *parent) : QMainWindow(parent), ui(new Ui:: { ui->setupUi(this); - /*-----------------------------------------------------*\ - | Lower process priority to potentially reduce | - | interference with other programs. Positive nice values| - | decrease priority on Linux | - \*-----------------------------------------------------*/ -#if defined(__linux__) || defined(__APPLE__) - setpriority(PRIO_PROCESS, 0, 10); -#endif -#ifdef _WIN32 - SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS); -#endif - /*-----------------------------------------------------*\ | Set window icon | \*-----------------------------------------------------*/