19#include <sys/resource.h>
20#include <sys/statvfs.h>
41 std::lock_guard<std::mutex> lock(mutex_);
46 return capabilities_.gpu.vendor;
51 std::lock_guard<std::mutex> lock(mutex_);
56 return capabilities_.gpu.vendorName;
61 std::lock_guard<std::mutex> lock(mutex_);
66 return capabilities_.kernel.isCachyOS;
71 std::lock_guard<std::mutex> lock(mutex_);
76 return capabilities_.kernel.supportsFsync;
81 std::lock_guard<std::mutex> lock(mutex_);
86 return capabilities_.kernel.supportsNTSync;
91 std::lock_guard<std::mutex> lock(mutex_);
96 return capabilities_.getRecommendedSyncMethod();
101 std::lock_guard<std::mutex> lock(mutex_);
104 detectDisplayServer();
106 return capabilities_.displayServer;
115 std::lock_guard<std::mutex> lock(mutex_);
120 return capabilities_.gpu;
125 std::lock_guard<std::mutex> lock(mutex_);
130 return capabilities_.cpu;
135 std::lock_guard<std::mutex> lock(mutex_);
140 return capabilities_.kernel;
145 std::lock_guard<std::mutex> lock(mutex_);
150 return capabilities_.tools;
155 std::lock_guard<std::mutex> lock(mutex_);
156 if (!initialized_ || capabilities_.runners.empty())
160 return capabilities_.runners;
165 std::lock_guard<std::mutex> lock(mutex_);
174 detectDisplayServer();
179 detectSystemReadiness();
181 lastFullRefresh_ = std::chrono::steady_clock::now();
183 return capabilities_;
188 std::lock_guard<std::mutex> lock(mutex_);
193 return capabilities_.memory;
198 std::lock_guard<std::mutex> lock(mutex_);
203 return capabilities_.monitors;
208 std::lock_guard<std::mutex> lock(mutex_);
213 return capabilities_.controllers;
218 std::lock_guard<std::mutex> lock(mutex_);
223 return capabilities_.storage;
228 std::lock_guard<std::mutex> lock(mutex_);
233 return capabilities_.power;
238 std::lock_guard<std::mutex> lock(mutex_);
241 detectSystemReadiness();
243 return capabilities_.systemReadiness;
252 std::lock_guard<std::mutex> lock(mutex_);
253 initialized_ =
false;
262 detectDisplayServer();
267 detectSystemReadiness();
270 lastFullRefresh_ = std::chrono::steady_clock::now();
276 std::lock_guard<std::mutex> lock(mutex_);
277 capabilities_.runners.clear();
279 lastRunnerRefresh_ = std::chrono::steady_clock::now();
290 std::vector<std::string> searchPaths = {
291 "/usr/bin/" + toolName,
292 "/usr/local/bin/" + toolName,
297 if (
const char* pathEnv = std::getenv(
"PATH"))
299 std::istringstream pathStream(pathEnv);
301 while (std::getline(pathStream, pathDir,
':'))
303 searchPaths.push_back(pathDir +
"/" + toolName);
307 for (
const auto& path : searchPaths)
309 if (std::filesystem::exists(path))
322void SystemInfoService::detectGPU()
330 for (
const auto& entry : std::filesystem::directory_iterator(
"/sys/class/drm"))
332 std::string name = entry.path().filename().string();
333 if (name.find(
"card") == 0 && name.find(
"-") == std::string::npos)
335 std::filesystem::path devicePath = entry.path() /
"device";
338 std::filesystem::path vendorPath = devicePath /
"vendor";
339 if (std::filesystem::exists(vendorPath))
341 std::ifstream vendorFile(vendorPath);
342 std::string vendorId;
343 if (vendorFile >> vendorId)
345 if (vendorId ==
"0x1002" || vendorId ==
"0x1022")
351 else if (vendorId ==
"0x10de")
356 else if (vendorId ==
"0x8086")
365 std::filesystem::path deviceIdPath = devicePath /
"device";
366 if (std::filesystem::exists(deviceIdPath))
368 std::ifstream deviceIdFile(deviceIdPath);
369 std::string deviceIdStr;
370 if (deviceIdFile >> deviceIdStr)
375 static_cast<uint16_t
>(std::stoul(deviceIdStr,
nullptr, 16));
384 std::filesystem::path ueventPath = devicePath /
"uevent";
385 if (std::filesystem::exists(ueventPath))
387 std::ifstream ueventFile(ueventPath);
389 while (std::getline(ueventFile, line))
391 if (line.find(
"PCI_SLOT_NAME=") == 0)
393 pciSlot = line.substr(14);
401 std::filesystem::path vramPath = devicePath /
"mem_info_vram_total";
402 if (std::filesystem::exists(vramPath))
404 std::ifstream vramFile(vramPath);
405 uint64_t vramBytes = 0;
406 if (vramFile >> vramBytes)
408 gpu.
vramMB = vramBytes / (1024 * 1024);
420 catch (
const std::exception& e)
426 if (!pciSlot.empty())
428 detectGPUModelFromLspci(pciSlot, gpu);
432 detectGPUGeneration();
435 detectDriverVersion();
439 std::filesystem::exists(
"/usr/share/vulkan/icd.d") ||
isToolAvailable(
"vulkaninfo");
446 Logger::info(
"Detected GPU: {} {} (Gen: {}, VRAM: {}MB, Vulkan: {}, Driver: {})",
452void SystemInfoService::detectGPUModelFromLspci(
const std::string& pciSlot,
GPUInfo& gpu)
460 static const std::regex pciSlotPattern(
"^[0-9a-fA-F:.]+$");
461 if (!std::regex_match(pciSlot, pciSlotPattern))
463 Logger::warn(
"detectGPUModelFromLspci: invalid PCI slot '{}', skipping lspci", pciSlot);
466 std::string cmd =
"lspci -s " + pciSlot +
" 2>/dev/null";
467 FILE* pipe = popen(cmd.c_str(),
"r");
470 Logger::warn(
"Failed to run lspci for GPU model detection");
481 while (fgets(buffer,
sizeof(buffer), pipe) !=
nullptr)
494 size_t colonPos = result.find(
':');
495 if (colonPos != std::string::npos)
498 colonPos = result.find(
':', colonPos + 1);
499 if (colonPos != std::string::npos)
501 std::string devicePart = result.substr(colonPos + 1);
504 size_t start = devicePart.find_first_not_of(
" \t\n\r");
505 size_t end = devicePart.find_last_not_of(
" \t\n\r");
506 if (start != std::string::npos && end != std::string::npos)
508 devicePart = devicePart.substr(start, end - start + 1);
512 size_t revPos = devicePart.rfind(
" (rev");
513 if (revPos != std::string::npos)
515 devicePart = devicePart.substr(0, revPos);
525 size_t amdBracket = devicePart.find(
"[AMD/ATI]");
526 if (amdBracket != std::string::npos)
528 devicePart = devicePart.substr(amdBracket + 9);
530 start = devicePart.find_first_not_of(
" \t");
531 if (start != std::string::npos)
533 devicePart = devicePart.substr(start);
536 gpu.
model = devicePart;
541 size_t nvPos = devicePart.find(
"NVIDIA Corporation");
542 if (nvPos != std::string::npos)
544 devicePart = devicePart.substr(nvPos + 18);
545 start = devicePart.find_first_not_of(
" \t");
546 if (start != std::string::npos)
548 devicePart = devicePart.substr(start);
551 gpu.
model = devicePart;
556 size_t intelPos = devicePart.find(
"Intel Corporation");
557 if (intelPos != std::string::npos)
559 devicePart = devicePart.substr(intelPos + 17);
560 start = devicePart.find_first_not_of(
" \t");
561 if (start != std::string::npos)
563 devicePart = devicePart.substr(start);
566 gpu.
model = devicePart;
570 gpu.
model = devicePart;
577 catch (
const std::exception& e)
579 Logger::warn(
"Error getting GPU model from lspci: {}", e.what());
583void SystemInfoService::detectGPUGeneration()
585 GPUInfo& gpu = capabilities_.gpu;
603 Logger::info(
"AMD GPU generation: {} (RDNA2+: {}, FSR3: {}, FSR4: {}, FSR4-on-RDNA3: {})",
622 Logger::info(
"NVIDIA GPU generation: {} (RTX: {}, DLSS: {}, DLSS3: {})",
637 Logger::info(
"Intel GPU generation: {} (Arc: {}, XeSS: {})",
648GPUGeneration SystemInfoService::detectAMDGenerationFromModel(
const std::string& model)
650 std::string modelLower = model;
651 std::transform(modelLower.begin(), modelLower.end(), modelLower.begin(),
652 [](
unsigned char c) { return static_cast<char>(::tolower(c)); });
655 if (modelLower.find(
"rx 90") != std::string::npos ||
656 modelLower.find(
"rx 9070") != std::string::npos ||
657 modelLower.find(
"rx 9060") != std::string::npos ||
658 modelLower.find(
"navi 48") != std::string::npos ||
659 modelLower.find(
"navi 44") != std::string::npos)
661 Logger::info(
"Detected RDNA4 from model name: {}", model);
666 if (modelLower.find(
"rx 79") != std::string::npos ||
667 modelLower.find(
"rx 78") != std::string::npos ||
668 modelLower.find(
"rx 77") != std::string::npos ||
669 modelLower.find(
"rx 76") != std::string::npos ||
670 modelLower.find(
"radeon 780m") != std::string::npos ||
671 modelLower.find(
"radeon 760m") != std::string::npos)
673 Logger::info(
"Detected RDNA3 from model name: {}", model);
678 if (modelLower.find(
"rx 69") != std::string::npos ||
679 modelLower.find(
"rx 68") != std::string::npos ||
680 modelLower.find(
"rx 67") != std::string::npos ||
681 modelLower.find(
"rx 66") != std::string::npos ||
682 modelLower.find(
"rx 65") != std::string::npos ||
683 modelLower.find(
"rx 64") != std::string::npos ||
684 modelLower.find(
"van gogh") != std::string::npos ||
685 modelLower.find(
"rembrandt") != std::string::npos ||
686 modelLower.find(
"radeon 680m") != std::string::npos ||
687 modelLower.find(
"radeon 660m") != std::string::npos)
689 Logger::info(
"Detected RDNA2 from model name: {}", model);
694 if (modelLower.find(
"rx 57") != std::string::npos ||
695 modelLower.find(
"rx 56") != std::string::npos ||
696 modelLower.find(
"rx 55") != std::string::npos)
698 Logger::info(
"Detected RDNA1 from model name: {}", model);
703 if (modelLower.find(
"vega") != std::string::npos ||
704 modelLower.find(
"radeon vii") != std::string::npos)
706 Logger::info(
"Detected Vega from model name: {}", model);
711 if (modelLower.find(
"rx 5") != std::string::npos &&
712 modelLower.find(
"rx 55") == std::string::npos &&
713 modelLower.find(
"rx 56") == std::string::npos &&
714 modelLower.find(
"rx 57") == std::string::npos)
716 Logger::info(
"Detected Polaris from model name: {}", model);
719 if (modelLower.find(
"rx 4") != std::string::npos)
721 Logger::info(
"Detected Polaris from model name: {}", model);
726 if (modelLower.find(
"r9 fury") != std::string::npos ||
727 modelLower.find(
"r9 nano") != std::string::npos ||
728 modelLower.find(
"r9 380") != std::string::npos ||
729 modelLower.find(
"r9 285") != std::string::npos ||
730 modelLower.find(
"fiji") != std::string::npos ||
731 modelLower.find(
"tonga") != std::string::npos)
733 Logger::info(
"Detected GCN4 from model name: {}", model);
738 if (modelLower.find(
"r9 29") != std::string::npos ||
739 modelLower.find(
"r7 260") != std::string::npos ||
740 modelLower.find(
"hawaii") != std::string::npos ||
741 modelLower.find(
"bonaire") != std::string::npos)
743 Logger::info(
"Detected GCN3 from model name: {}", model);
748 if (modelLower.find(
"r9 270") != std::string::npos ||
749 modelLower.find(
"r7 250") != std::string::npos ||
750 modelLower.find(
"r7 240") != std::string::npos ||
751 modelLower.find(
"oland") != std::string::npos)
753 Logger::info(
"Detected GCN2 from model name: {}", model);
758 if (modelLower.find(
"hd 79") != std::string::npos ||
759 modelLower.find(
"hd 78") != std::string::npos ||
760 modelLower.find(
"hd 77") != std::string::npos ||
761 modelLower.find(
"hd 76") != std::string::npos ||
762 modelLower.find(
"tahiti") != std::string::npos ||
763 modelLower.find(
"pitcairn") != std::string::npos ||
764 modelLower.find(
"cape verde") != std::string::npos)
766 Logger::info(
"Detected GCN1 from model name: {}", model);
771 if (modelLower.find(
"hd 69") != std::string::npos ||
772 modelLower.find(
"hd 68") != std::string::npos ||
773 modelLower.find(
"hd 67") != std::string::npos ||
774 modelLower.find(
"hd 66") != std::string::npos ||
775 modelLower.find(
"hd 65") != std::string::npos ||
776 modelLower.find(
"hd 64") != std::string::npos ||
777 modelLower.find(
"cayman") != std::string::npos ||
778 modelLower.find(
"barts") != std::string::npos ||
779 modelLower.find(
"turks") != std::string::npos)
781 Logger::info(
"Detected TeraScale (HD 6000) from model name: {}", model);
786 if (modelLower.find(
"hd 58") != std::string::npos ||
787 modelLower.find(
"hd 57") != std::string::npos ||
788 modelLower.find(
"hd 56") != std::string::npos ||
789 modelLower.find(
"hd 55") != std::string::npos ||
790 modelLower.find(
"hd 54") != std::string::npos ||
791 modelLower.find(
"cypress") != std::string::npos ||
792 modelLower.find(
"juniper") != std::string::npos ||
793 modelLower.find(
"redwood") != std::string::npos ||
794 modelLower.find(
"cedar") != std::string::npos)
796 Logger::info(
"Detected TeraScale (HD 5000) from model name: {}", model);
801 if (modelLower.find(
"hd 48") != std::string::npos ||
802 modelLower.find(
"hd 47") != std::string::npos ||
803 modelLower.find(
"hd 46") != std::string::npos ||
804 modelLower.find(
"hd 45") != std::string::npos ||
805 modelLower.find(
"hd 43") != std::string::npos ||
806 modelLower.find(
"hd 38") != std::string::npos ||
807 modelLower.find(
"hd 36") != std::string::npos ||
808 modelLower.find(
"hd 34") != std::string::npos ||
809 modelLower.find(
"hd 29") != std::string::npos ||
810 modelLower.find(
"hd 26") != std::string::npos ||
811 modelLower.find(
"hd 24") != std::string::npos)
813 Logger::info(
"Detected TeraScale (HD 2000-4000) from model name: {}", model);
817 Logger::warn(
"Could not determine AMD generation from model: {}", model);
821GPUGeneration SystemInfoService::detectNVIDIAGenerationFromModel(
const std::string& model)
823 std::string modelLower = model;
824 std::transform(modelLower.begin(), modelLower.end(), modelLower.begin(),
825 [](
unsigned char c) { return static_cast<char>(::tolower(c)); });
828 if (modelLower.find(
"rtx 40") != std::string::npos ||
829 modelLower.find(
"rtx 4090") != std::string::npos ||
830 modelLower.find(
"rtx 4080") != std::string::npos ||
831 modelLower.find(
"rtx 4070") != std::string::npos ||
832 modelLower.find(
"rtx 4060") != std::string::npos ||
833 modelLower.find(
"rtx 4050") != std::string::npos)
835 Logger::info(
"Detected Ada from model name: {}", model);
840 if (modelLower.find(
"rtx 30") != std::string::npos ||
841 modelLower.find(
"rtx 3090") != std::string::npos ||
842 modelLower.find(
"rtx 3080") != std::string::npos ||
843 modelLower.find(
"rtx 3070") != std::string::npos ||
844 modelLower.find(
"rtx 3060") != std::string::npos ||
845 modelLower.find(
"rtx 3050") != std::string::npos ||
846 modelLower.find(
"rtx a") != std::string::npos)
848 Logger::info(
"Detected Ampere from model name: {}", model);
853 if (modelLower.find(
"rtx 20") != std::string::npos ||
854 modelLower.find(
"rtx 2080") != std::string::npos ||
855 modelLower.find(
"rtx 2070") != std::string::npos ||
856 modelLower.find(
"rtx 2060") != std::string::npos ||
857 modelLower.find(
"gtx 16") != std::string::npos ||
858 modelLower.find(
"gtx 1660") != std::string::npos ||
859 modelLower.find(
"gtx 1650") != std::string::npos)
861 Logger::info(
"Detected Turing from model name: {}", model);
866 if (modelLower.find(
"gtx 10") != std::string::npos ||
867 modelLower.find(
"gtx 1080") != std::string::npos ||
868 modelLower.find(
"gtx 1070") != std::string::npos ||
869 modelLower.find(
"gtx 1060") != std::string::npos ||
870 modelLower.find(
"gtx 1050") != std::string::npos ||
871 modelLower.find(
"titan x") != std::string::npos)
873 Logger::info(
"Detected Pascal from model name: {}", model);
877 Logger::warn(
"Could not determine NVIDIA generation from model: {}", model);
881GPUGeneration SystemInfoService::detectIntelGenerationFromModel(
const std::string& model)
883 std::string modelLower = model;
884 std::transform(modelLower.begin(), modelLower.end(), modelLower.begin(),
885 [](
unsigned char c) { return static_cast<char>(::tolower(c)); });
888 if (modelLower.find(
"arc a") != std::string::npos ||
889 modelLower.find(
"arc a770") != std::string::npos ||
890 modelLower.find(
"arc a750") != std::string::npos ||
891 modelLower.find(
"arc a580") != std::string::npos ||
892 modelLower.find(
"arc a380") != std::string::npos ||
893 modelLower.find(
"arc a310") != std::string::npos)
895 Logger::info(
"Detected Intel Arc from model name: {}", model);
900 if (modelLower.find(
"xe") != std::string::npos ||
901 modelLower.find(
"iris xe") != std::string::npos ||
902 modelLower.find(
"uhd 7") != std::string::npos)
904 Logger::info(
"Detected Intel Xe from model name: {}", model);
908 Logger::warn(
"Could not determine Intel generation from model: {}", model);
912GPUGeneration SystemInfoService::detectAMDGeneration(uint16_t deviceId)
920 if ((deviceId >= 0x7550 && deviceId <= 0x756F) ||
921 (deviceId >= 0x7590 && deviceId <= 0x75AF))
923 Logger::debug(
"GPU detected as RDNA4 (device ID: 0x{:04x})", deviceId);
929 if ((deviceId >= 0x7440 && deviceId <= 0x747F) ||
930 (deviceId >= 0x7480 && deviceId <= 0x74BF) ||
931 (deviceId >= 0x74C0 && deviceId <= 0x74FF) ||
932 (deviceId >= 0x15BF && deviceId <= 0x15EF) ||
933 deviceId == 0x744C || deviceId == 0x7448)
935 Logger::debug(
"GPU detected as RDNA3 (device ID: 0x{:04x})", deviceId);
941 if ((deviceId >= 0x73A0 && deviceId <= 0x73FF) ||
942 (deviceId >= 0x73BF && deviceId <= 0x73EF) ||
943 (deviceId >= 0x7420 && deviceId <= 0x743F) ||
944 (deviceId >= 0x1638 && deviceId <= 0x164F) ||
945 (deviceId >= 0x1681 && deviceId <= 0x169F) ||
946 deviceId == 0x73AF || deviceId == 0x73BF ||
947 deviceId == 0x73DF || deviceId == 0x73EF ||
948 deviceId == 0x73FF || deviceId == 0x7421 ||
949 deviceId == 0x7422 || deviceId == 0x7423 ||
952 Logger::debug(
"GPU detected as RDNA2 (device ID: 0x{:04x})", deviceId);
958 if ((deviceId >= 0x7310 && deviceId <= 0x7340) ||
959 (deviceId >= 0x7340 && deviceId <= 0x735F) ||
960 deviceId == 0x731F || deviceId == 0x7312 ||
961 deviceId == 0x7318 || deviceId == 0x7319 ||
962 deviceId == 0x7340 || deviceId == 0x7341)
964 Logger::debug(
"GPU detected as RDNA1 (device ID: 0x{:04x})", deviceId);
969 if ((deviceId >= 0x6860 && deviceId <= 0x6880) ||
970 (deviceId >= 0x66A0 && deviceId <= 0x66BF) ||
971 deviceId == 0x687F || deviceId == 0x6867 ||
974 Logger::debug(
"GPU detected as Vega (device ID: 0x{:04x})", deviceId);
979 if ((deviceId >= 0x67C0 && deviceId <= 0x67FF) ||
980 (deviceId >= 0x6980 && deviceId <= 0x69BF) ||
981 deviceId == 0x67DF || deviceId == 0x67EF ||
984 Logger::debug(
"GPU detected as Polaris (device ID: 0x{:04x})", deviceId);
989 if ((deviceId >= 0x6920 && deviceId <= 0x6939) ||
990 (deviceId >= 0x7300 && deviceId <= 0x730F) ||
991 deviceId == 0x692B || deviceId == 0x692F ||
992 deviceId == 0x6930 || deviceId == 0x6938 ||
995 Logger::debug(
"GPU detected as GCN4 (device ID: 0x{:04x})", deviceId);
1000 if ((deviceId >= 0x67A0 && deviceId <= 0x67BF) ||
1001 (deviceId >= 0x6640 && deviceId <= 0x665F) ||
1002 deviceId == 0x67B0 || deviceId == 0x67B1 ||
1003 deviceId == 0x6640 || deviceId == 0x6641 ||
1004 deviceId == 0x6646 || deviceId == 0x6647 ||
1005 deviceId == 0x6649 || deviceId == 0x665C)
1007 Logger::debug(
"GPU detected as GCN3 (device ID: 0x{:04x})", deviceId);
1012 if ((deviceId >= 0x6600 && deviceId <= 0x663F) ||
1013 deviceId == 0x6600 || deviceId == 0x6601 ||
1014 deviceId == 0x6604 || deviceId == 0x6605 ||
1015 deviceId == 0x6610 || deviceId == 0x6611 ||
1016 deviceId == 0x6808 || deviceId == 0x6809 ||
1017 deviceId == 0x6810 || deviceId == 0x6811)
1019 Logger::debug(
"GPU detected as GCN2 (device ID: 0x{:04x})", deviceId);
1024 if ((deviceId >= 0x6780 && deviceId <= 0x67A0) ||
1025 (deviceId >= 0x6800 && deviceId <= 0x683F) ||
1026 (deviceId >= 0x6820 && deviceId <= 0x685F) ||
1027 deviceId == 0x6780 || deviceId == 0x6784 ||
1028 deviceId == 0x6788 || deviceId == 0x678A ||
1029 deviceId == 0x6798 || deviceId == 0x679A ||
1030 deviceId == 0x6800 || deviceId == 0x6801 ||
1031 deviceId == 0x6818 || deviceId == 0x6819 ||
1032 deviceId == 0x6820 || deviceId == 0x6821 ||
1033 deviceId == 0x6823 || deviceId == 0x6824 ||
1034 deviceId == 0x6825 || deviceId == 0x6826 ||
1035 deviceId == 0x6827 || deviceId == 0x6660 ||
1036 deviceId == 0x6663 || deviceId == 0x6664 ||
1037 deviceId == 0x6665 || deviceId == 0x6667)
1039 Logger::debug(
"GPU detected as GCN1 (device ID: 0x{:04x})", deviceId);
1044 if ((deviceId >= 0x6700 && deviceId <= 0x673F) ||
1045 (deviceId >= 0x6740 && deviceId <= 0x677F) ||
1046 (deviceId >= 0x6840 && deviceId <= 0x687F &&
1047 deviceId < 0x6860) ||
1048 deviceId == 0x6718 ||
1049 deviceId == 0x6719 ||
1050 deviceId == 0x671C || deviceId == 0x671D ||
1051 deviceId == 0x6720 || deviceId == 0x6738 ||
1052 deviceId == 0x6739 || deviceId == 0x6759 ||
1053 deviceId == 0x6840 || deviceId == 0x6841 ||
1054 deviceId == 0x6842 || deviceId == 0x6843)
1056 Logger::debug(
"GPU detected as TeraScale (HD 6000, device ID: 0x{:04x})", deviceId);
1061 if ((deviceId >= 0x6880 && deviceId <= 0x68BF) ||
1062 (deviceId >= 0x68C0 && deviceId <= 0x68FF) ||
1063 (deviceId >= 0x68A0 && deviceId <= 0x68BF) ||
1064 deviceId == 0x6898 || deviceId == 0x6899 ||
1065 deviceId == 0x689B || deviceId == 0x689C ||
1066 deviceId == 0x68B8 || deviceId == 0x68B9 ||
1067 deviceId == 0x68BA || deviceId == 0x68BE ||
1068 deviceId == 0x68C0 || deviceId == 0x68C1 ||
1069 deviceId == 0x68D8 || deviceId == 0x68D9 ||
1070 deviceId == 0x68E0 || deviceId == 0x68E1)
1072 Logger::debug(
"GPU detected as TeraScale (HD 5000, device ID: 0x{:04x})", deviceId);
1077 if ((deviceId >= 0x9400 && deviceId <= 0x94FF) ||
1078 (deviceId >= 0x9500 && deviceId <= 0x95FF) ||
1079 (deviceId >= 0x9440 && deviceId <= 0x949F) ||
1080 (deviceId >= 0x94C0 && deviceId <= 0x94FF) ||
1081 (deviceId >= 0x9540 && deviceId <= 0x957F) ||
1082 (deviceId >= 0x9580 && deviceId <= 0x95FF) ||
1083 (deviceId >= 0x9600 && deviceId <= 0x96FF) ||
1084 (deviceId >= 0x9700 && deviceId <= 0x97FF))
1086 Logger::debug(
"GPU detected as TeraScale (HD 2000-4000, device ID: 0x{:04x})", deviceId);
1090 Logger::debug(
"GPU detected as AMD_Older (device ID: 0x{:04x})", deviceId);
1094GPUGeneration SystemInfoService::detectNVIDIAGeneration(uint16_t deviceId)
1102 if ((deviceId >= 0x2680 && deviceId <= 0x27FF) ||
1103 (deviceId >= 0x2780 && deviceId <= 0x27BF) ||
1104 deviceId == 0x2684 || deviceId == 0x2702 ||
1105 deviceId == 0x2704 || deviceId == 0x2705 ||
1106 deviceId == 0x2782 || deviceId == 0x2783 ||
1109 Logger::debug(
"GPU detected as NVIDIA Ada (device ID: 0x{:04x})", deviceId);
1115 if ((deviceId >= 0x2200 && deviceId <= 0x267F) ||
1116 deviceId == 0x2204 || deviceId == 0x2206 ||
1117 deviceId == 0x2208 || deviceId == 0x220A ||
1118 deviceId == 0x2216 || deviceId == 0x2231 ||
1119 deviceId == 0x2414 || deviceId == 0x2420 ||
1120 deviceId == 0x2482 || deviceId == 0x2484 ||
1121 deviceId == 0x2503 || deviceId == 0x2504 ||
1122 deviceId == 0x2507 || deviceId == 0x2508 ||
1123 deviceId == 0x2520 || deviceId == 0x2531)
1125 Logger::debug(
"GPU detected as NVIDIA Ampere (device ID: 0x{:04x})", deviceId);
1130 if ((deviceId >= 0x1E00 && deviceId <= 0x21FF) ||
1131 deviceId == 0x1E02 || deviceId == 0x1E04 ||
1132 deviceId == 0x1E07 || deviceId == 0x1E30 ||
1133 deviceId == 0x1E81 || deviceId == 0x1E82 ||
1134 deviceId == 0x1E87 || deviceId == 0x1E89 ||
1135 deviceId == 0x1F02 || deviceId == 0x1F06 ||
1136 deviceId == 0x1F07 || deviceId == 0x1F08 ||
1137 deviceId == 0x1F82 || deviceId == 0x1F91 ||
1138 deviceId == 0x2182 || deviceId == 0x2184 ||
1139 deviceId == 0x2187 || deviceId == 0x2188 ||
1140 deviceId == 0x1F0A || deviceId == 0x1F12)
1142 Logger::debug(
"GPU detected as NVIDIA Turing (device ID: 0x{:04x})", deviceId);
1147 if ((deviceId >= 0x1B00 && deviceId <= 0x1DFF) ||
1148 deviceId == 0x1B00 || deviceId == 0x1B02 ||
1149 deviceId == 0x1B06 || deviceId == 0x1B80 ||
1150 deviceId == 0x1B81 || deviceId == 0x1B82 ||
1151 deviceId == 0x1B83 || deviceId == 0x1B84 ||
1152 deviceId == 0x1C02 || deviceId == 0x1C03 ||
1153 deviceId == 0x1C81 || deviceId == 0x1C82 ||
1156 Logger::debug(
"GPU detected as NVIDIA Pascal (device ID: 0x{:04x})", deviceId);
1160 Logger::debug(
"GPU detected as NVIDIA_Older (device ID: 0x{:04x})", deviceId);
1164GPUGeneration SystemInfoService::detectIntelGeneration(uint16_t deviceId)
1169 if (deviceId >= 0x5690 && deviceId <= 0x56FF)
1171 if (deviceId >= 0x9A00 && deviceId <= 0x9AFF)
1177void SystemInfoService::detectCPU()
1179 CPUInfo& cpu = capabilities_.cpu;
1183 std::ifstream cpuinfo(
"/proc/cpuinfo");
1185 int processorCount = 0;
1187 while (std::getline(cpuinfo, line))
1189 if (line.find(
"model name") == 0)
1191 size_t colonPos = line.find(
':');
1192 if (colonPos != std::string::npos && cpu.
model.empty())
1194 cpu.
model = line.substr(colonPos + 2);
1197 if (cpu.
model.find(
"AMD") != std::string::npos)
1201 else if (cpu.
model.find(
"Intel") != std::string::npos)
1207 else if (line.find(
"processor") == 0)
1211 else if (line.find(
"cpu cores") == 0)
1213 size_t colonPos = line.find(
':');
1214 if (colonPos != std::string::npos && cpu.
coreCount == 0)
1218 cpu.
coreCount = std::stoi(line.substr(colonPos + 2));
1225 else if (line.find(
"cpu MHz") == 0)
1227 size_t colonPos = line.find(
':');
1228 if (colonPos != std::string::npos && cpu.
frequencyMHz == 0.0)
1232 cpu.
frequencyMHz = std::stod(line.substr(colonPos + 2));
1248 if (cpu.
vendor ==
"Intel")
1252 std::ifstream hybridCheck(
"/sys/devices/system/cpu/cpu0/topology/core_type");
1253 if (hybridCheck.is_open())
1264 catch (
const std::exception& e)
1270 detectCPUGovernor();
1273void SystemInfoService::detectKernel()
1275 KernelInfo& kernel = capabilities_.kernel;
1280 std::ifstream versionFile(
"/proc/version");
1281 std::string versionLine;
1282 if (std::getline(versionFile, versionLine))
1285 std::regex versionRegex(R
"(Linux version (\S+))");
1287 if (std::regex_search(versionLine, match, versionRegex))
1289 kernel.
version = match[1].str();
1292 std::regex numRegex(R
"((\d+)\.(\d+)\.?(\d*))");
1293 std::smatch numMatch;
1294 if (std::regex_search(kernel.
version, numMatch, numRegex))
1298 if (numMatch[3].length() > 0)
1306 if (versionLine.find(
"cachyos") != std::string::npos ||
1307 versionLine.find(
"CachyOS") != std::string::npos)
1320 std::ifstream osRelease(
"/etc/os-release");
1322 while (std::getline(osRelease, line))
1324 if (line.find(
"NAME=") == 0)
1326 size_t start = line.find(
'"');
1327 size_t end = line.rfind(
'"');
1328 if (start != std::string::npos && end != std::string::npos && end > start)
1330 kernel.
distro = line.substr(start + 1, end - start - 1);
1334 kernel.
distro = line.substr(5);
1337 if (kernel.
distro.find(
"CachyOS") != std::string::npos)
1350 bool foundFsyncSymbol =
false;
1354 std::ifstream kallsyms(
"/proc/kallsyms");
1356 while (std::getline(kallsyms, line))
1358 if (line.find(
"futex_waitv") != std::string::npos)
1362 foundFsyncSymbol =
true;
1372 if (!foundFsyncSymbol)
1374 bool kernelSupports =
1377 kernel.
fsyncStatus = kernelSupports ?
"available" :
"kernel_too_old";
1384 detectKernelParams();
1390 "Detected kernel: {} (distro: {}, fsync: {}, ntsync: {} [loaded: {}], CachyOS: {})",
1398void SystemInfoService::detectNTSync()
1400 KernelInfo& kernel = capabilities_.kernel;
1405 bool ntsyncKernelOk =
1410 bool ntsyncDeviceExists = std::filesystem::exists(
"/dev/ntsync");
1411 bool ntsyncModuleExists = std::filesystem::exists(
"/sys/module/ntsync");
1414 bool moduleLoaded = ntsyncDeviceExists || ntsyncModuleExists;
1421 std::ifstream kallsyms(
"/proc/kallsyms");
1423 while (std::getline(kallsyms, line))
1425 if (line.find(
"ntsync") != std::string::npos)
1427 moduleLoaded =
true;
1439 if (!ntsyncKernelOk && !moduleLoaded)
1445 else if (ntsyncKernelOk && !moduleLoaded)
1451 else if (moduleLoaded)
1464void SystemInfoService::detectKernelParams()
1466 KernelInfo& kernel = capabilities_.kernel;
1471 std::ifstream maxMapFile(
"/proc/sys/vm/max_map_count");
1485 std::ifstream swappinessFile(
"/proc/sys/vm/swappiness");
1495 Logger::info(
"Kernel params: max_map_count={} (ok: {}), swappiness={} (ok: {})",
1500void SystemInfoService::detectTools()
1502 ToolAvailability& tools = capabilities_.tools;
1524 isToolAvailable(
"vkbasalt") || std::filesystem::exists(
"/usr/share/vkBasalt/vkBasalt.conf");
1535 std::filesystem::exists(
"/usr/lib/systemd/system/power-profiles-daemon.service");
1542 const int rc = std::system(
"systemctl is-active --quiet ananicy-cpp.service 2>/dev/null");
1546 Logger::info(
"Detected tools: MangoHud={}, GameMode={}, game-performance={}, VkBasalt={}, "
1547 "Gamescope={}, power-profiles={}, ananicy-cpp={}",
1554void SystemInfoService::detectRunners()
1556 std::vector<RunnerInfo>& runners = capabilities_.runners;
1562 for (
const auto& [name, path] : protonVersions)
1566 info.
path = path.string();
1570 std::string nameLower = name;
1571 std::transform(nameLower.begin(), nameLower.end(), nameLower.begin(),
1572 [](
unsigned char c) { return static_cast<char>(::tolower(c)); });
1574 if (nameLower.find(
"cachyos") != std::string::npos)
1576 info.
type =
"proton-cachyos";
1578 else if (nameLower.find(
"ge-proton") != std::string::npos)
1580 info.
type =
"proton-ge";
1582 else if (nameLower.find(
"proton") != std::string::npos)
1584 info.
type =
"proton";
1586 else if (nameLower.find(
"wine") != std::string::npos)
1592 info.
type =
"proton";
1595 runners.push_back(std::move(info));
1602 sysWine.
name =
"System Wine";
1604 sysWine.
type =
"wine";
1605 runners.push_back(std::move(sysWine));
1611void SystemInfoService::detectDisplayServer()
1614 if (
const char* sessionType = std::getenv(
"XDG_SESSION_TYPE"))
1616 std::string type = sessionType;
1617 if (type ==
"wayland")
1623 else if (type ==
"x11")
1632 if (std::getenv(
"WAYLAND_DISPLAY"))
1635 Logger::info(
"Display server: Wayland (via WAYLAND_DISPLAY)");
1637 else if (std::getenv(
"DISPLAY"))
1653void SystemInfoService::detectMemory()
1655 MemoryInfo& mem = capabilities_.memory;
1659 std::ifstream meminfo(
"/proc/meminfo");
1662 while (std::getline(meminfo, line))
1664 if (line.find(
"MemTotal:") == 0)
1667 std::istringstream iss(line);
1670 iss >> label >> value;
1673 else if (line.find(
"MemAvailable:") == 0)
1675 std::istringstream iss(line);
1678 iss >> label >> value;
1681 else if (line.find(
"SwapTotal:") == 0)
1683 std::istringstream iss(line);
1686 iss >> label >> value;
1689 else if (line.find(
"SwapFree:") == 0)
1691 std::istringstream iss(line);
1694 iss >> label >> value;
1702 catch (
const std::exception& e)
1712void SystemInfoService::detectDriverVersion()
1714 GPUInfo& gpu = capabilities_.gpu;
1721 std::ifstream nvVersion(
"/proc/driver/nvidia/version");
1723 if (std::getline(nvVersion, line))
1726 std::regex versionRegex(R
"((\d+\.\d+\.\d+))");
1728 if (std::regex_search(line, match, versionRegex))
1745 std::ifstream mesaVersion(
"/usr/share/doc/mesa/version");
1746 if (mesaVersion.is_open())
1754 for (
const auto& entry : std::filesystem::directory_iterator(
"/sys/class/drm"))
1756 std::string name = entry.path().filename().string();
1757 if (name.find(
"card") == 0 && name.find(
"-") == std::string::npos)
1759 std::filesystem::path driverPath = entry.path() /
"device/driver";
1760 if (std::filesystem::exists(driverPath))
1762 auto resolved = std::filesystem::read_symlink(driverPath);
1763 std::string driverName = resolved.filename().string();
1764 if (driverName ==
"amdgpu" || driverName ==
"radeon" ||
1765 driverName ==
"i915")
1790void SystemInfoService::detectCPUGovernor()
1792 CPUInfo& cpu = capabilities_.cpu;
1797 std::ifstream govFile(
"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor");
1798 if (govFile.is_open())
1800 std::getline(govFile, cpu.
governor);
1804 std::ifstream maxFreqFile(
"/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq");
1805 if (maxFreqFile.is_open())
1807 uint64_t maxFreqKHz;
1808 maxFreqFile >> maxFreqKHz;
1814 catch (
const std::exception& e)
1816 Logger::warn(
"Error detecting CPU governor: {}", e.what());
1820void SystemInfoService::detectScheduler()
1822 CPUInfo& cpu = capabilities_.cpu;
1833 bool schedExtSupported = std::filesystem::exists(
"/sys/kernel/sched_ext");
1836 if (schedExtSupported)
1839 std::ifstream stateFile(
"/sys/kernel/sched_ext/state");
1840 if (stateFile.is_open())
1843 std::getline(stateFile, state);
1846 if (state.find(
"enabled") != std::string::npos)
1849 std::ifstream nameFile(
"/sys/kernel/sched_ext/root/name");
1850 if (nameFile.is_open())
1852 std::string schedName;
1853 std::getline(nameFile, schedName);
1857 if (schedName.find(
"lavd") != std::string::npos ||
1858 schedName.find(
"LAVD") != std::string::npos)
1861 Logger::info(
"Detected scheduler: sched-ext LAVD (gaming-optimized)");
1863 else if (schedName.find(
"rusty") != std::string::npos)
1868 else if (schedName.find(
"bpfland") != std::string::npos)
1876 Logger::info(
"Detected scheduler: sched-ext ({})", schedName);
1887 std::ifstream schedFile(
"/sys/kernel/debug/sched/features");
1888 if (schedFile.is_open())
1890 std::string features;
1891 std::getline(schedFile, features);
1893 if (features.find(
"BORE") != std::string::npos)
1904 const auto& kernel = capabilities_.kernel;
1908 Logger::info(
"Detected scheduler: EEVDF (kernel 6.6+)");
1926void SystemInfoService::detectMonitors()
1928 std::vector<MonitorInfo>& monitors = capabilities_.monitors;
1934 for (
const auto& entry : std::filesystem::directory_iterator(
"/sys/class/drm"))
1936 std::string name = entry.path().filename().string();
1939 if (name.find(
"card") != 0 || name.find(
"-") == std::string::npos)
1943 std::filesystem::path statusPath = entry.path() /
"status";
1944 if (!std::filesystem::exists(statusPath))
1947 std::ifstream statusFile(statusPath);
1949 std::getline(statusFile, status);
1951 if (status !=
"connected")
1954 MonitorInfo monitor;
1957 size_t dashPos = name.find(
'-');
1958 if (dashPos != std::string::npos)
1960 monitor.
connector = name.substr(dashPos + 1);
1964 std::filesystem::path edidPath = entry.path() /
"edid";
1965 if (std::filesystem::exists(edidPath))
1972 std::filesystem::path modesPath = entry.path() /
"modes";
1973 if (std::filesystem::exists(modesPath))
1975 std::ifstream modesFile(modesPath);
1976 std::string firstMode;
1977 if (std::getline(modesFile, firstMode))
1980 std::regex modeRegex(R
"((\d+)x(\d+)(?:@(\d+))?)");
1982 if (std::regex_match(firstMode, match, modeRegex))
1986 if (match[3].matched)
1995 std::filesystem::path vrrPath = entry.path() /
"vrr_capable";
1996 if (std::filesystem::exists(vrrPath))
1998 std::ifstream vrrFile(vrrPath);
2000 vrrFile >> vrrCapable;
2005 std::filesystem::path hdrPath = entry.path() /
"hdr_output_metadata";
2006 if (std::filesystem::exists(hdrPath))
2015 monitors.push_back(std::move(monitor));
2018 Logger::info(
"Detected {} monitor(s)", monitors.size());
2019 for (
const auto& m : monitors)
2021 Logger::info(
" {} : {}x{} @{:.0f}Hz VRR={} HDR={}", m.connector, m.widthPixels,
2022 m.heightPixels, m.refreshRate, m.supportsVRR ?
"yes" :
"no",
2023 m.supportsHDR ?
"yes" :
"no");
2026 catch (
const std::exception& e)
2028 Logger::warn(
"Error detecting monitors: {}", e.what());
2036void SystemInfoService::detectControllers()
2038 std::vector<ControllerInfo>& controllers = capabilities_.controllers;
2039 controllers.clear();
2044 for (
const auto& entry : std::filesystem::directory_iterator(
"/dev/input"))
2046 std::string name = entry.path().filename().string();
2049 if (name.find(
"js") != 0)
2053 std::filesystem::path sysPath =
"/sys/class/input/" + name +
"/device";
2055 if (!std::filesystem::exists(sysPath))
2058 ControllerInfo controller;
2059 controller.
path = entry.path().string();
2062 std::filesystem::path namePath = sysPath /
"name";
2063 if (std::filesystem::exists(namePath))
2065 std::ifstream nameFile(namePath);
2066 std::getline(nameFile, controller.
name);
2070 std::filesystem::path idPath = sysPath /
"id";
2071 if (std::filesystem::exists(idPath))
2073 std::filesystem::path vendorPath = idPath /
"vendor";
2074 std::filesystem::path productPath = idPath /
"product";
2076 if (std::filesystem::exists(vendorPath))
2078 std::ifstream vendorFile(vendorPath);
2079 std::string vendorStr;
2080 vendorFile >> vendorStr;
2084 static_cast<uint16_t
>(std::stoul(vendorStr,
nullptr, 16));
2091 if (std::filesystem::exists(productPath))
2093 std::ifstream productFile(productPath);
2094 std::string productStr;
2095 productFile >> productStr;
2099 static_cast<uint16_t
>(std::stoul(productStr,
nullptr, 16));
2111 std::string nameLower = controller.
name;
2112 std::transform(nameLower.begin(), nameLower.end(), nameLower.begin(),
2113 [](
unsigned char c) { return static_cast<char>(::tolower(c)); });
2114 controller.
isWireless = (nameLower.find(
"bluetooth") != std::string::npos ||
2115 nameLower.find(
"wireless") != std::string::npos);
2117 controllers.push_back(std::move(controller));
2120 Logger::info(
"Detected {} controller(s)", controllers.size());
2121 for (
const auto& c : controllers)
2123 Logger::info(
" {} ({}) VID={:04x} PID={:04x}", c.name, c.type, c.vendorId,
2127 catch (
const std::exception& e)
2129 Logger::warn(
"Error detecting controllers: {}", e.what());
2133std::string SystemInfoService::detectControllerType(uint16_t vendorId, uint16_t productId)
2138 constexpr uint16_t VENDOR_MICROSOFT = 0x045e;
2139 constexpr uint16_t VENDOR_SONY = 0x054c;
2140 constexpr uint16_t VENDOR_NINTENDO = 0x057e;
2141 constexpr uint16_t VENDOR_VALVE = 0x28de;
2142 constexpr uint16_t VENDOR_8BITDO = 0x2dc8;
2146 case VENDOR_MICROSOFT:
2149 return "playstation";
2150 case VENDOR_NINTENDO:
2165void SystemInfoService::detectStorage()
2167 std::vector<StorageInfo>& storage = capabilities_.storage;
2173 std::ifstream mounts(
"/proc/mounts");
2176 while (std::getline(mounts, line))
2178 std::istringstream iss(line);
2179 std::string device, mountPoint, fsType;
2180 iss >> device >> mountPoint >> fsType;
2183 if (device.find(
"/dev/") != 0)
2187 if (fsType ==
"tmpfs" || fsType ==
"devtmpfs" || fsType ==
"proc" ||
2188 fsType ==
"sysfs" || fsType ==
"cgroup" || fsType ==
"cgroup2")
2197 info.
type = detectStorageType(device);
2200 struct statvfs stat;
2201 if (statvfs(mountPoint.c_str(), &stat) == 0)
2203 info.
totalGB = (stat.f_blocks * stat.f_frsize) / (1024ULL * 1024 * 1024);
2204 info.
freeGB = (stat.f_bavail * stat.f_frsize) / (1024ULL * 1024 * 1024);
2208 std::string deviceName = std::filesystem::path(device).filename().string();
2210 while (!deviceName.empty() &&
2211 std::isdigit(
static_cast<unsigned char>(deviceName.back())))
2213 deviceName.pop_back();
2216 if (deviceName.size() > 1 && deviceName.back() ==
'p' &&
2217 deviceName.find(
"nvme") != std::string::npos)
2219 deviceName.pop_back();
2222 std::filesystem::path discardPath =
2223 "/sys/block/" + deviceName +
"/queue/discard_max_bytes";
2224 if (std::filesystem::exists(discardPath))
2226 std::ifstream discardFile(discardPath);
2227 uint64_t discardMax = 0;
2228 discardFile >> discardMax;
2229 info.
isTRIM = (discardMax > 0);
2232 storage.push_back(std::move(info));
2235 Logger::info(
"Detected {} mount point(s)", storage.size());
2236 for (
const auto& s : storage)
2238 Logger::info(
" {} on {} ({}) - {} {}GB free/{}GB", s.device, s.mountPoint,
2244 s.freeGB, s.totalGB);
2247 catch (
const std::exception& e)
2253StorageType SystemInfoService::detectStorageType(
const std::string& device)
2255 std::string deviceName = std::filesystem::path(device).filename().string();
2258 while (!deviceName.empty() && std::isdigit(
static_cast<unsigned char>(deviceName.back())))
2260 deviceName.pop_back();
2263 if (deviceName.size() > 1 && deviceName.back() ==
'p' &&
2264 deviceName.find(
"nvme") != std::string::npos)
2266 deviceName.pop_back();
2270 if (deviceName.find(
"nvme") != std::string::npos)
2276 std::filesystem::path rotationalPath =
"/sys/block/" + deviceName +
"/queue/rotational";
2277 if (std::filesystem::exists(rotationalPath))
2279 std::ifstream rotFile(rotationalPath);
2281 rotFile >> rotational;
2291 std::string bestMatch;
2296 if (path.find(s.mountPoint) == 0)
2298 if (s.mountPoint.length() > bestMatch.length())
2300 bestMatch = s.mountPoint;
2313void SystemInfoService::detectPower()
2320 std::filesystem::path powerSupplyPath =
"/sys/class/power_supply";
2321 if (std::filesystem::exists(powerSupplyPath))
2323 for (
const auto& entry : std::filesystem::directory_iterator(powerSupplyPath))
2326 std::filesystem::path typePath = entry.path() /
"type";
2327 if (std::filesystem::exists(typePath))
2329 std::ifstream typeFile(typePath);
2331 std::getline(typeFile, type);
2333 if (type ==
"Battery")
2338 std::filesystem::path statusPath = entry.path() /
"status";
2339 if (std::filesystem::exists(statusPath))
2341 std::ifstream statusFile(statusPath);
2343 std::getline(statusFile, status);
2344 power.
onBattery = (status ==
"Discharging");
2348 std::filesystem::path capacityPath = entry.path() /
"capacity";
2349 if (std::filesystem::exists(capacityPath))
2351 std::ifstream capacityFile(capacityPath);
2365 if (capabilities_.tools.powerProfilesDaemon)
2369 std::filesystem::path profilePath =
"/var/lib/power-profiles-daemon/power_profile";
2370 if (std::filesystem::exists(profilePath))
2372 std::ifstream profileFile(profilePath);
2390 Logger::info(
"Power: laptop={}, onBattery={}, battery={}%, profile={}",
2395 catch (
const std::exception& e)
2397 Logger::warn(
"Error detecting power info: {}", e.what());
2407 std::vector<std::string> result;
2411 result.push_back(
"vm.max_map_count is " + std::to_string(
maxMapCount) +
2412 " (should be >= 1048576). Some games may crash. "
2413 "Fix: sudo sysctl -w vm.max_map_count=1048576");
2419 result.push_back(
"kernel.split_lock_mitigate is " + val +
2420 " (should be 0). Some games may stutter. "
2421 "Fix: sudo sysctl -w kernel.split_lock_mitigate=0");
2426 result.push_back(
"Open file limit (RLIMIT_NOFILE) is " + std::to_string(
nofileSoft) +
2427 " (should be >= 524288). Some games may fail to load assets. "
2428 "Fix: Add '* soft nofile 524288' to /etc/security/limits.conf");
2435 "' (should be 'madvise'). Performance may be inconsistent. "
2436 "Fix: echo madvise | sudo tee /sys/kernel/mm/transparent_hugepage/enabled");
2446void SystemInfoService::detectSystemReadiness()
2453 std::ifstream maxMapFile(
"/proc/sys/vm/max_map_count");
2466 std::ifstream splitLockFile(
"/proc/sys/kernel/split_lock_mitigate");
2482 if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
2484 readiness.
nofileSoft =
static_cast<uint64_t
>(rl.rlim_cur);
2495 std::ifstream thpFile(
"/sys/kernel/mm/transparent_hugepage/enabled");
2497 if (std::getline(thpFile, line))
2500 auto bracketStart = line.find(
'[');
2501 auto bracketEnd = line.find(
']');
2502 if (bracketStart != std::string::npos && bracketEnd != std::string::npos)
2504 readiness.
thpSetting = line.substr(bracketStart + 1, bracketEnd - bracketStart - 1);
2517 Logger::info(
"System readiness: max_map_count={} (ok: {}), split_lock={} (ok: {}), "
2518 "nofile={} (ok: {}), thp='{}' (ok: {}), all_ok={}",
2522 readiness.
thpOk ?
"yes" :
"no", readiness.
allOk() ?
"yes" :
"no");
static void info(const std::string &message, Args &&... args)
Log info message (general information).
static void debug(const std::string &message, Args &&... args)
Log debug message (verbose development info).
static void warn(const std::string &message, Args &&... args)
Log warning message (non-critical issue).
static std::vector< std::pair< std::string, std::filesystem::path > > scanProtonVersions()
Scan for all installed Proton versions.
std::string getToolPath(const std::string &toolName)
Get path to tool binary.
static SystemInfoService & instance()
Get singleton instance.
std::string getRecommendedSyncMethod()
Get recommended sync method as string.
const std::vector< RunnerInfo > & getInstalledRunners()
Get all installed runners (Proton/Wine versions).
GPUVendor getGPUVendor()
Get GPU vendor.
const SystemCapabilities & getCapabilities()
Get complete system capabilities.
const std::vector< MonitorInfo > & getMonitors()
Get connected monitors.
const ToolAvailability & getToolAvailability()
Get available performance tools.
const SystemReadiness & getSystemReadiness()
Get system readiness checks.
const MemoryInfo & getMemoryInfo()
Get memory information.
bool isCachyOS()
Check if running on CachyOS.
void refresh()
Force refresh of all cached data.
void refreshRunners()
Refresh only runner list (faster than full refresh).
bool isToolAvailable(const std::string &toolName)
Check if tool is available by name.
bool supportsFsync()
Check if fsync is supported.
const KernelInfo & getKernelInfo()
Get kernel information.
SystemInfoService(const SystemInfoService &)=delete
DisplayServer getDisplayServer()
Get display server type.
const GPUInfo & getGPUInfo()
Get full GPU information.
bool supportsNTSync()
Check if NTSync is supported (kernel 6.2+ with module loaded).
const std::vector< StorageInfo > & getStorageInfo()
Get storage information.
std::string getGPUVendorName()
Get GPU vendor name as string.
const PowerInfo & getPowerInfo()
Get power/battery information.
const CPUInfo & getCPUInfo()
Get full CPU information.
const std::vector< ControllerInfo > & getControllers()
Get connected controllers.
Detected CPU information.
Detected GPU information.
bool isRTXCapable() const
bool isRDNA3OrNewer() const
bool isRDNA2OrNewer() const
std::string driverVersion
Kernel version and feature support.
System memory information.
Power and thermal information.
std::string activeProfile
Complete system capabilities summary.
StorageType getStorageTypeForPath(const std::string &path) const
SystemReadiness systemReadiness
std::vector< StorageInfo > storage
System readiness checks for optimal gaming.
std::vector< std::string > warnings() const