mirror of
https://github.com/hyprwm/hyprsysteminfo.git
synced 2025-12-20 07:10:02 +01:00
Compare commits
15 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe81610278 | ||
| b8ee10565d | |||
|
|
3feb86f866 | ||
| 6769e50fcf | |||
| ca1a0434c4 | |||
| 17f041e2d5 | |||
| 9d07b2e7c7 | |||
| 54ce0e6243 | |||
| 5351581605 | |||
| 3498fad4c4 | |||
| 8b271e2ba3 | |||
| 0fa58f189b | |||
| 2104e356be | |||
| dc474b07f6 | |||
| 9c5f02ff68 |
14 changed files with 225 additions and 22 deletions
31
.github/workflows/nix.yml
vendored
31
.github/workflows/nix.yml
vendored
|
|
@ -7,8 +7,35 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: DeterminateSystems/nix-installer-action@main
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
- name: Install Nix
|
||||
uses: nixbuild/nix-quick-install-action@v31
|
||||
with:
|
||||
nix_conf: |
|
||||
keep-env-derivations = true
|
||||
keep-outputs = true
|
||||
|
||||
- name: Restore and save Nix store
|
||||
uses: nix-community/cache-nix-action@v6
|
||||
with:
|
||||
# restore and save a cache using this key
|
||||
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
|
||||
# if there's no cache hit, restore a cache by this prefix
|
||||
restore-prefixes-first-match: nix-${{ runner.os }}-
|
||||
# collect garbage until the Nix store size (in bytes) is at most this number
|
||||
# before trying to save a new cache
|
||||
# 1G = 1073741824
|
||||
gc-max-store-size-linux: 1G
|
||||
# do purge caches
|
||||
purge: true
|
||||
# purge all versions of the cache
|
||||
purge-prefixes: nix-${{ runner.os }}-
|
||||
# created more than this number of seconds ago
|
||||
purge-created: 0
|
||||
# or, last accessed more than this number of seconds ago
|
||||
# relative to the start of the `Post Restore and save Nix store` phase
|
||||
purge-last-accessed: 0
|
||||
# except any version with the key that is the same as the `primary-key`
|
||||
purge-primary-key: never
|
||||
|
||||
# not needed (yet)
|
||||
# - uses: cachix/cachix-action@v12
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ project(hsi VERSION ${VER} LANGUAGES CXX)
|
|||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(Qt6 6.5 REQUIRED COMPONENTS Widgets Quick QuickControls2)
|
||||
find_package(Qt6 6.5 REQUIRED COMPONENTS Widgets Quick QuickControls2 WaylandClient)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
pkg_check_modules(hyprutils REQUIRED IMPORTED_TARGET hyprutils)
|
||||
|
|
|
|||
2
VERSION
2
VERSION
|
|
@ -1 +1 @@
|
|||
0.1.0
|
||||
0.1.3
|
||||
92
flake.lock
generated
92
flake.lock
generated
|
|
@ -1,6 +1,83 @@
|
|||
{
|
||||
"nodes": {
|
||||
"hyprland-qt-support": {
|
||||
"inputs": {
|
||||
"hyprlang": "hyprlang",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"systems": [
|
||||
"systems"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1737634706,
|
||||
"narHash": "sha256-nGCibkfsXz7ARx5R+SnisRtMq21IQIhazp6viBU8I/A=",
|
||||
"owner": "hyprwm",
|
||||
"repo": "hyprland-qt-support",
|
||||
"rev": "8810df502cdee755993cb803eba7b23f189db795",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hyprwm",
|
||||
"repo": "hyprland-qt-support",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"hyprlang": {
|
||||
"inputs": {
|
||||
"hyprutils": "hyprutils",
|
||||
"nixpkgs": [
|
||||
"hyprland-qt-support",
|
||||
"nixpkgs"
|
||||
],
|
||||
"systems": [
|
||||
"hyprland-qt-support",
|
||||
"systems"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1737634606,
|
||||
"narHash": "sha256-W7W87Cv6wqZ9PHegI6rH1+ve3zJPiyevMFf0/HwdbCQ=",
|
||||
"owner": "hyprwm",
|
||||
"repo": "hyprlang",
|
||||
"rev": "f41271d35cc0f370d300413d756c2677f386af9d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hyprwm",
|
||||
"repo": "hyprlang",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"hyprutils": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"hyprland-qt-support",
|
||||
"hyprlang",
|
||||
"nixpkgs"
|
||||
],
|
||||
"systems": [
|
||||
"hyprland-qt-support",
|
||||
"hyprlang",
|
||||
"systems"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1737632363,
|
||||
"narHash": "sha256-X9I8POSlHxBVjD0fiX1O2j7U9Zi1+4rIkrsyHP0uHXY=",
|
||||
"owner": "hyprwm",
|
||||
"repo": "hyprutils",
|
||||
"rev": "006620eb29d54ea9086538891404c78563d1bae1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hyprwm",
|
||||
"repo": "hyprutils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"hyprutils_2": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
|
|
@ -10,11 +87,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1727300645,
|
||||
"narHash": "sha256-OvAtVLaSRPnbXzOwlR1fVqCXR7i+ICRX3aPMCdIiv+c=",
|
||||
"lastModified": 1737632363,
|
||||
"narHash": "sha256-X9I8POSlHxBVjD0fiX1O2j7U9Zi1+4rIkrsyHP0uHXY=",
|
||||
"owner": "hyprwm",
|
||||
"repo": "hyprutils",
|
||||
"rev": "3f5293432b6dc6a99f26aca2eba3876d2660665c",
|
||||
"rev": "006620eb29d54ea9086538891404c78563d1bae1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -25,11 +102,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1728492678,
|
||||
"narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=",
|
||||
"lastModified": 1737469691,
|
||||
"narHash": "sha256-nmKOgAU48S41dTPIXAq0AHZSehWUn6ZPrUKijHAMmIk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "5633bcff0c6162b9e4b5f1264264611e950c8ec7",
|
||||
"rev": "9e4d5190a9482a1fb9d18adf0bdb83c6e506eaab",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -41,7 +118,8 @@
|
|||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"hyprutils": "hyprutils",
|
||||
"hyprland-qt-support": "hyprland-qt-support",
|
||||
"hyprutils": "hyprutils_2",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"systems": "systems"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,12 @@
|
|||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
inputs.systems.follows = "systems";
|
||||
};
|
||||
|
||||
hyprland-qt-support = {
|
||||
url = "github:hyprwm/hyprland-qt-support";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
inputs.systems.follows = "systems";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
pkg-config,
|
||||
hyprutils,
|
||||
pciutils,
|
||||
kdePackages,
|
||||
hyprland-qt-support,
|
||||
version ? "0",
|
||||
}: let
|
||||
inherit (lib.strings) makeBinPath;
|
||||
|
|
@ -31,8 +31,7 @@ in
|
|||
qt6.qtsvg
|
||||
qt6.qtwayland
|
||||
hyprutils
|
||||
kdePackages.qqc2-desktop-style
|
||||
kdePackages.kirigami
|
||||
hyprland-qt-support
|
||||
];
|
||||
|
||||
preFixup = ''
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ in {
|
|||
|
||||
hyprsysteminfo = lib.composeManyExtensions [
|
||||
inputs.hyprutils.overlays.default
|
||||
inputs.hyprland-qt-support.overlays.default
|
||||
(final: prev: {
|
||||
hyprsysteminfo = final.callPackage ./. {
|
||||
version = "${version}+date=${date}_${self.shortRev or "dirty"}";
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@
|
|||
qtbase
|
||||
qtdeclarative
|
||||
qtwayland
|
||||
pkgs.kdePackages.qqc2-desktop-style
|
||||
# see https://github.com/NixOS/nixpkgs/blob/e186dd1a34be7a76c6e2c038ab4b759faec32d5d/pkgs/kde/frameworks/kirigami/default.nix#L9-L11
|
||||
pkgs.kdePackages.kirigami.unwrapped
|
||||
pkgs.hyprland-qt-support
|
||||
]);
|
||||
in ''
|
||||
# Add Qt-related environment variables.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
find_package(Qt6 REQUIRED COMPONENTS WaylandClientPrivate)
|
||||
|
||||
qt_add_executable(hyprsysteminfo
|
||||
main.cpp
|
||||
util/Utils.cpp
|
||||
SystemInfo.cpp
|
||||
SystemIconProvider.cpp
|
||||
WaylandScreen.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(hyprsysteminfo
|
||||
|
|
@ -11,4 +14,6 @@ qt_add_qml_module(hyprsysteminfo
|
|||
QML_FILES main.qml
|
||||
)
|
||||
|
||||
target_link_libraries(hyprsysteminfo PRIVATE Qt6::Widgets Qt6::QuickControls2 PkgConfig::hyprutils)
|
||||
target_link_libraries(hyprsysteminfo PRIVATE
|
||||
Qt6::Widgets Qt6::QuickControls2 Qt6::WaylandClientPrivate PkgConfig::hyprutils
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include "SystemInfo.hpp"
|
||||
#include "WaylandScreen.hpp"
|
||||
#include "util/Utils.hpp"
|
||||
#include <qclipboard.h>
|
||||
#include <array>
|
||||
|
|
@ -19,10 +20,13 @@
|
|||
#include <sys/utsname.h>
|
||||
#include <hyprutils/string/VarList.hpp>
|
||||
#include <hyprutils/string/String.hpp>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace Hyprutils::String;
|
||||
|
||||
CSystemInternals::CSystemInternals(QObject* parent) : QObject(parent) {
|
||||
setenv("LC_ALL", "en_US.UTF-8", true);
|
||||
|
||||
// gather data from os-release
|
||||
if (auto data = readFile("/etc/os-release")) {
|
||||
CVarList lines(data.value(), 0, '\n');
|
||||
|
|
@ -187,9 +191,8 @@ CSystemInternals::CSystemInternals(QObject* parent) : QObject(parent) {
|
|||
|
||||
{
|
||||
std::string screens;
|
||||
for (auto* s : QGuiApplication::screens()) {
|
||||
auto ratio = s->devicePixelRatio();
|
||||
screens += std::format("{} ({}x{}), ", s->name().toStdString(), s->geometry().width() * ratio, s->geometry().height() * ratio);
|
||||
for (const auto& s : SWaylandScreenInfo::enumerateScreens()) {
|
||||
screens += std::format("{} ({}x{}), ", s.name.toStdString(), s.pixelSize.width(), s.pixelSize.height());
|
||||
}
|
||||
|
||||
if (!screens.empty())
|
||||
|
|
|
|||
60
src/WaylandScreen.cpp
Normal file
60
src/WaylandScreen.cpp
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
#include "WaylandScreen.hpp"
|
||||
|
||||
#include <QtWaylandClient/private/qwayland-wayland.h>
|
||||
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
|
||||
#include <QtWaylandClient/private/qwaylandintegration_p.h>
|
||||
#include <cstdint>
|
||||
#include <qcontainerfwd.h>
|
||||
#include <qsize.h>
|
||||
#include <qstringliteral.h>
|
||||
#include <qtclasshelpermacros.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace QtWaylandClient;
|
||||
|
||||
class CWaylandScreen : public QtWayland::wl_output {
|
||||
public:
|
||||
explicit CWaylandScreen(QWaylandDisplay* display, uint32_t version, uint32_t id);
|
||||
~CWaylandScreen() override;
|
||||
Q_DISABLE_COPY_MOVE(CWaylandScreen);
|
||||
SWaylandScreenInfo info;
|
||||
|
||||
protected:
|
||||
void output_mode(uint32_t flags, int32_t width, int32_t height, int32_t refresh) override;
|
||||
void output_name(const QString& name) override;
|
||||
};
|
||||
|
||||
std::vector<SWaylandScreenInfo> SWaylandScreenInfo::enumerateScreens() {
|
||||
auto* display = QWaylandIntegration::instance()->display();
|
||||
|
||||
std::vector<CWaylandScreen*> screens;
|
||||
for (const auto& global : display->globals()) {
|
||||
if (global.interface == QStringLiteral("wl_output")) {
|
||||
screens.emplace_back(new CWaylandScreen(display, global.version, global.id));
|
||||
}
|
||||
}
|
||||
|
||||
display->forceRoundTrip();
|
||||
|
||||
std::vector<SWaylandScreenInfo> info;
|
||||
for (auto* screen : screens) {
|
||||
info.push_back(screen->info);
|
||||
delete screen;
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
CWaylandScreen::CWaylandScreen(QWaylandDisplay* display, uint32_t version, uint32_t id) : QtWayland::wl_output(display->wl_registry(), id, 4u) {}
|
||||
|
||||
CWaylandScreen::~CWaylandScreen() {
|
||||
release();
|
||||
}
|
||||
|
||||
void CWaylandScreen::output_mode(uint32_t flags, int width, int height, int refresh) {
|
||||
info.pixelSize = QSize(width, height);
|
||||
}
|
||||
|
||||
void CWaylandScreen::output_name(const QString& name) {
|
||||
info.name = name;
|
||||
}
|
||||
14
src/WaylandScreen.hpp
Normal file
14
src/WaylandScreen.hpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include <qcontainerfwd.h>
|
||||
#include <qsize.h>
|
||||
#include <qstring.h>
|
||||
#include <qcontainerfwd.h>
|
||||
#include <vector>
|
||||
|
||||
struct SWaylandScreenInfo {
|
||||
QString name;
|
||||
QSize pixelSize;
|
||||
|
||||
static std::vector<SWaylandScreenInfo> enumerateScreens();
|
||||
};
|
||||
|
|
@ -10,7 +10,7 @@ int main(int argc, char* argv[]) {
|
|||
app.setApplicationName("Hyprland System Info");
|
||||
|
||||
if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE"))
|
||||
QQuickStyle::setStyle("org.kde.desktop");
|
||||
QQuickStyle::setStyle("org.hyprland.style");
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.addImageProvider("systemIcons", new CSystemIconProvider);
|
||||
|
|
|
|||
12
src/main.qml
12
src/main.qml
|
|
@ -36,6 +36,11 @@ ApplicationWindow {
|
|||
Layout.rightMargin: fontMetrics.height * 8
|
||||
}
|
||||
|
||||
SystemPalette {
|
||||
id: system
|
||||
colorGroup: SystemPalette.Active
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: mainLayout
|
||||
spacing: fontMetrics.height
|
||||
|
|
@ -77,16 +82,19 @@ ApplicationWindow {
|
|||
Layout.alignment: Qt.AlignVCenter
|
||||
|
||||
Label {
|
||||
color: system.windowText
|
||||
text: SystemInfo.systemName
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
}
|
||||
|
||||
Label {
|
||||
color: system.windowText
|
||||
text: SystemInfo.systemUrl
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
}
|
||||
|
||||
Label {
|
||||
color: system.windowText
|
||||
text: SystemInfo.systemKernel
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
}
|
||||
|
|
@ -119,16 +127,19 @@ ApplicationWindow {
|
|||
Layout.alignment: Qt.AlignVCenter
|
||||
|
||||
Label {
|
||||
color: system.windowText
|
||||
text: "Hyprland"
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
}
|
||||
|
||||
Label {
|
||||
color: system.windowText
|
||||
text: SystemInfo.hyprlandVersion
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
}
|
||||
|
||||
Label {
|
||||
color: system.windowText
|
||||
visible: SystemInfo.hyprlandVersion != text
|
||||
text: SystemInfo.hyprlandVersionLong
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
|
@ -147,6 +158,7 @@ ApplicationWindow {
|
|||
Layout.rightMargin: fontMetrics.height * 4
|
||||
|
||||
component DetailsLabel: Label {
|
||||
color: system.windowText
|
||||
Layout.fillWidth: true
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.NoWrap
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue