Compare commits

...

15 commits
v0.1.0 ... main

Author SHA1 Message Date
VuaTech
fe81610278
cmake: Added fing_pkg for WaylandClientPrivate (#21) 2025-10-04 00:32:24 +02:00
b8ee10565d
CI/Nix: add cache-nix-action
Use nixbuild/nix-quick-install-action which pairs well with
nix-community/cache-nix-action.

Should help with build times by reducing the number of packages needing
to be re-downloaded on each run.

Parameters are taken from https://github.com/nix-community/cache-nix-action
and may be tweaked later.
2025-06-20 01:27:46 +03:00
Yuxuan Sun
3feb86f866
core: fix en_US language enforcement in cmds (#20) 2025-06-05 21:36:10 +01:00
6769e50fcf
CI: remove deprecated magic-nix-cache-action 2025-02-08 23:11:54 +02:00
ca1a0434c4
flake.lock: update 2025-01-23 14:40:55 +02:00
17f041e2d5 version: bump to 0.1.3 2025-01-10 16:53:10 +01:00
9d07b2e7c7
flake.lock: update 2025-01-09 23:35:43 +02:00
54ce0e6243
nix: move to hyprland-qt-support (#13) 2025-01-08 22:38:20 +00:00
5351581605 core: move to hyprland-qt-support instead of KDE's qqc2 2025-01-08 23:04:03 +01:00
3498fad4c4 version: bump to 0.1.2 2025-01-02 14:53:32 +01:00
8b271e2ba3 qml: force system theme for label colors
ref #11
2024-10-17 18:06:53 +01:00
0fa58f189b
core: fix reported display resolutions when fractionally scaled (#10)
Qt appears to have no way to retrieve the pixel size sent by wayland,
as it overrides it with the logical size and will not return the
physical one.
2024-10-17 12:15:07 +01:00
2104e356be core: enforce en_US language in cmds
ref #9
2024-10-16 19:48:42 +01:00
dc474b07f6 version: bump to 0.1.1 2024-10-16 16:00:54 +01:00
9c5f02ff68 core: use screen size not geom 2024-10-16 15:49:31 +01:00
14 changed files with 225 additions and 22 deletions

View file

@ -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

View file

@ -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)

View file

@ -1 +1 @@
0.1.0
0.1.3

92
flake.lock generated
View file

@ -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"
}

View file

@ -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 = {

View file

@ -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 = ''

View file

@ -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"}";

View file

@ -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.

View file

@ -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
)

View file

@ -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
View 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
View 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();
};

View file

@ -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);

View file

@ -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