diff --git a/assets/showcase.png b/assets/showcase.png index 5f1a7cc..a934f49 100644 Binary files a/assets/showcase.png and b/assets/showcase.png differ diff --git a/qml/main.qml b/qml/main.qml index 2663e60..1536788 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -151,6 +151,26 @@ ApplicationWindow { Layout.leftMargin: 60 Layout.rightMargin: 60 + Text { + visible: hsi.getUserAt().length() > 0 + text: "User: " + hsi.getUserAt() + Layout.maximumWidth: _width - 120 + color: system.windowText + elide: Text.ElideRight + textFormat: Text.PlainText + wrapMode: Text.NoWrap + } + + Text { + visible: hsi.getModel().length() > 0 + text: "Model: " + hsi.getModel() + Layout.maximumWidth: _width - 120 + color: system.windowText + elide: Text.ElideRight + textFormat: Text.PlainText + wrapMode: Text.NoWrap + } + Text { text: "CPU: " + hsi.getCPUInfo() Layout.maximumWidth: _width - 120 @@ -185,6 +205,33 @@ ApplicationWindow { wrapMode: Text.NoWrap } + Text { + text: "DE: " + hsi.getDE() + Layout.maximumWidth: _width - 120 + color: system.windowText + elide: Text.ElideRight + textFormat: Text.PlainText + wrapMode: Text.NoWrap + } + + Text { + text: "Uptime: " + hsi.getUptime() + Layout.maximumWidth: _width - 120 + color: system.windowText + elide: Text.ElideRight + textFormat: Text.PlainText + wrapMode: Text.NoWrap + } + + Text { + text: "Displays: " + hsi.getDisplays() + Layout.maximumWidth: _width - 120 + color: system.windowText + elide: Text.ElideRight + textFormat: Text.PlainText + wrapMode: Text.NoWrap + } + } Rectangle { diff --git a/qmlSources/SystemInternals.hpp b/qmlSources/SystemInternals.hpp index 153fe1e..7280f0f 100644 --- a/qmlSources/SystemInternals.hpp +++ b/qmlSources/SystemInternals.hpp @@ -23,6 +23,8 @@ class CSystemInternals : public QObject { QString hlSystemInfo = "[error]", hlSystemVersion = "[error]"; + QString uptime = "unknown", DE = "Unknown", screens = "unknown", board = "", user = ""; + Q_INVOKABLE bool hasSystemLogoName() { return systemLogoName.size() > 0; } @@ -73,6 +75,26 @@ class CSystemInternals : public QObject { return ramInfo; } + Q_INVOKABLE QString getDE() { + return DE; + } + + Q_INVOKABLE QString getUptime() { + return uptime; + } + + Q_INVOKABLE QString getDisplays() { + return screens; + } + + Q_INVOKABLE QString getModel() { + return board; + } + + Q_INVOKABLE QString getUserAt() { + return user; + } + Q_INVOKABLE void copySystemInfo(); Q_INVOKABLE void copyVersion(); }; diff --git a/src/main.cpp b/src/main.cpp index d27b7f9..120ec5c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include "util/Utils.hpp" @@ -12,7 +13,19 @@ #include using namespace Hyprutils::String; -static void getSystemInfo(CSystemInternals* hsi) { +static std::string readFile(const std::string& filename) { + try { + std::ifstream ifs(filename); + if (ifs.good()) { + std::string data(std::istreambuf_iterator{ifs}, {}); + ifs.close(); + return trim(data); + } + } catch (...) { return "[error]"; } + return "[error]"; +} + +static void getSystemInfo(CSystemInternals* hsi, QGuiApplication* app) { // gather data from os-release std::ifstream osInfo("/etc/os-release"); @@ -147,6 +160,31 @@ static void getSystemInfo(CSystemInternals* hsi) { hsi->ramInfo = std::format("{} / {}", ramIntToReadable(props[2]), ramIntToReadable(props[1])).c_str(); } } + + // other, misc + if (const auto DE = getenv("XDG_CURRENT_DESKTOP"); DE) + hsi->DE = DE; + + if (const auto UPTIME = execAndGet("uptime -p"); !UPTIME.empty()) + hsi->uptime = trim(UPTIME.find("up ") == 0 ? UPTIME.substr(3) : UPTIME).c_str(); + + { + std::string screens; + + for (auto& s : app->screens()) { + screens += std::format("{} ({}x{}), ", s->name().toStdString(), s->geometry().width(), s->geometry().height()); + } + + if (!screens.empty()) + screens = screens.substr(0, screens.length() - 2); + + hsi->screens = screens.c_str(); + } + + hsi->user = std::format("{}@{}", trim(execAndGet("whoami")), readFile("/etc/hostname")).c_str(); + + if (const auto BOARD = readFile("/sys/devices/virtual/dmi/id/board_name"); BOARD != "[error]") + hsi->board = BOARD.c_str(); } int main(int argc, char* argv[]) { @@ -158,7 +196,7 @@ int main(int argc, char* argv[]) { auto systemInternals = new CSystemInternals; - getSystemInfo(systemInternals); + getSystemInfo(systemInternals, &app); QQmlApplicationEngine engine; engine.rootContext()->setContextProperty("hsi", systemInternals);