mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-27 23:37:05 -05:00
feat: show Linux distribution information on startup (#1729)
This commit is contained in:
@@ -597,6 +597,16 @@ namespace hex {
|
|||||||
*/
|
*/
|
||||||
std::string getArchitecture();
|
std::string getArchitecture();
|
||||||
|
|
||||||
|
|
||||||
|
struct LinuxDistro {
|
||||||
|
std::string name;
|
||||||
|
std::string version;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* @brief Gets information related to the Linux distribution, if running on Linux
|
||||||
|
*/
|
||||||
|
std::optional<LinuxDistro> getLinuxDistro();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets the current ImHex version
|
* @brief Gets the current ImHex version
|
||||||
* @return ImHex version
|
* @return ImHex version
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <imgui_internal.h>
|
#include <imgui_internal.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <fstream>
|
||||||
|
#include <algorithm>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#if defined(OS_WINDOWS)
|
#if defined(OS_WINDOWS)
|
||||||
@@ -742,6 +744,25 @@ namespace hex {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<LinuxDistro> getLinuxDistro() {
|
||||||
|
std::ifstream file("/etc/os-release");
|
||||||
|
std::string name;
|
||||||
|
std::string version;
|
||||||
|
|
||||||
|
std::string line;
|
||||||
|
while (std::getline(file, line)) {
|
||||||
|
if (line.find("PRETTY_NAME=") != std::string::npos) {
|
||||||
|
name = line.substr(line.find("=") + 1);
|
||||||
|
name.erase(std::remove(name.begin(), name.end(), '\"'), name.end());
|
||||||
|
} else if (line.find("VERSION_ID=") != std::string::npos) {
|
||||||
|
version = line.substr(line.find("=") + 1);
|
||||||
|
version.erase(std::remove(version.begin(), version.end(), '\"'), version.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {{name, version}};
|
||||||
|
}
|
||||||
|
|
||||||
std::string getImHexVersion(bool withBuildType) {
|
std::string getImHexVersion(bool withBuildType) {
|
||||||
#if defined IMHEX_VERSION
|
#if defined IMHEX_VERSION
|
||||||
if (withBuildType) {
|
if (withBuildType) {
|
||||||
|
|||||||
@@ -43,6 +43,11 @@ int main(int argc, char **argv) {
|
|||||||
log::info("Welcome to ImHex {}!", ImHexApi::System::getImHexVersion());
|
log::info("Welcome to ImHex {}!", ImHexApi::System::getImHexVersion());
|
||||||
log::info("Compiled using commit {}@{}", ImHexApi::System::getCommitBranch(), ImHexApi::System::getCommitHash());
|
log::info("Compiled using commit {}@{}", ImHexApi::System::getCommitBranch(), ImHexApi::System::getCommitHash());
|
||||||
log::info("Running on {} {} ({})", ImHexApi::System::getOSName(), ImHexApi::System::getOSVersion(), ImHexApi::System::getArchitecture());
|
log::info("Running on {} {} ({})", ImHexApi::System::getOSName(), ImHexApi::System::getOSVersion(), ImHexApi::System::getArchitecture());
|
||||||
|
#if defined(OS_LINUX)
|
||||||
|
auto distro = ImHexApi::System::getLinuxDistro().value();
|
||||||
|
log::info("Linux distribution: {}. Version: {}", distro.name, distro.version == "" ? "None" : distro.version);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Run ImHex
|
// Run ImHex
|
||||||
return init::runImHex();
|
return init::runImHex();
|
||||||
|
|||||||
Reference in New Issue
Block a user