From d9657a95cb6706860332ff47dad444a96bcc874a Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Thu, 4 Dec 2025 17:59:47 +0000 Subject: hyprctl: use new hyprpaper ipc format (#12537) --------- Co-authored-by: Mihai Fufezan --- .github/actions/setup_base/action.yml | 9 + .gitignore | 2 + flake.lock | 27 ++ flake.nix | 7 + hyprctl/CMakeLists.txt | 25 +- hyprctl/Strings.hpp | 186 ----------- hyprctl/hw-protocols/hyprpaper_core.xml | 144 +++++++++ hyprctl/main.cpp | 539 -------------------------------- hyprctl/src/Strings.hpp | 183 +++++++++++ hyprctl/src/helpers/Memory.hpp | 11 + hyprctl/src/hyprpaper/Hyprpaper.cpp | 148 +++++++++ hyprctl/src/hyprpaper/Hyprpaper.hpp | 8 + hyprctl/src/main.cpp | 539 ++++++++++++++++++++++++++++++++ nix/default.nix | 3 + nix/overlays.nix | 1 + 15 files changed, 1105 insertions(+), 727 deletions(-) delete mode 100644 hyprctl/Strings.hpp create mode 100644 hyprctl/hw-protocols/hyprpaper_core.xml delete mode 100644 hyprctl/main.cpp create mode 100644 hyprctl/src/Strings.hpp create mode 100644 hyprctl/src/helpers/Memory.hpp create mode 100644 hyprctl/src/hyprpaper/Hyprpaper.cpp create mode 100644 hyprctl/src/hyprpaper/Hyprpaper.hpp create mode 100644 hyprctl/src/main.cpp diff --git a/.github/actions/setup_base/action.yml b/.github/actions/setup_base/action.yml index 665d7f07..b586566d 100644 --- a/.github/actions/setup_base/action.yml +++ b/.github/actions/setup_base/action.yml @@ -75,6 +75,15 @@ runs: cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` cmake --install build + - name: Get hyprwire-git + shell: bash + run: | + git clone https://github.com/hyprwm/hyprwire --recursive + cd hyprwire + cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build + cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` + cmake --install build + - name: Get hyprutils-git shell: bash run: | diff --git a/.gitignore b/.gitignore index 4ced1678..669e215b 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,8 @@ src/render/shaders/*.inc src/render/shaders/Shaders.hpp hyprctl/hyprctl +hyprctl/hw-protocols/*.c* +hyprctl/hw-protocols/*.h* gmon.out *.out diff --git a/flake.lock b/flake.lock index 6db66e40..95b0cecf 100644 --- a/flake.lock +++ b/flake.lock @@ -297,6 +297,32 @@ "type": "github" } }, + "hyprwire": { + "inputs": { + "hyprutils": [ + "hyprutils" + ], + "nixpkgs": [ + "nixpkgs" + ], + "systems": [ + "systems" + ] + }, + "locked": { + "lastModified": 1764773840, + "narHash": "sha256-9UcCdwe7vPgEcJJ64JseBQL0ZJZoxp/2iFuvfRI+9zk=", + "owner": "hyprwm", + "repo": "hyprwire", + "rev": "3f1997d6aeced318fb141810fded2255da811293", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprwire", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1764517877, @@ -345,6 +371,7 @@ "hyprlang": "hyprlang", "hyprutils": "hyprutils", "hyprwayland-scanner": "hyprwayland-scanner", + "hyprwire": "hyprwire", "nixpkgs": "nixpkgs", "pre-commit-hooks": "pre-commit-hooks", "systems": "systems", diff --git a/flake.nix b/flake.nix index 6799144b..49f82cdf 100644 --- a/flake.nix +++ b/flake.nix @@ -65,6 +65,13 @@ inputs.systems.follows = "systems"; }; + hyprwire = { + url = "github:hyprwm/hyprwire"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.systems.follows = "systems"; + inputs.hyprutils.follows = "hyprutils"; + }; + xdph = { url = "github:hyprwm/xdg-desktop-portal-hyprland"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/hyprctl/CMakeLists.txt b/hyprctl/CMakeLists.txt index db5ef615..7071ede9 100644 --- a/hyprctl/CMakeLists.txt +++ b/hyprctl/CMakeLists.txt @@ -5,11 +5,32 @@ project( DESCRIPTION "Control utility for Hyprland" ) -pkg_check_modules(hyprctl_deps REQUIRED IMPORTED_TARGET hyprutils>=0.2.4 re2) +pkg_check_modules(hyprctl_deps REQUIRED IMPORTED_TARGET hyprutils>=0.2.4 hyprwire re2) -add_executable(hyprctl "main.cpp") +file(GLOB_RECURSE HYPRCTL_SRCFILES CONFIGURE_DEPENDS "src/*.cpp" "hw-protocols/*.cpp" "include/*.hpp") + +add_executable(hyprctl ${HYPRCTL_SRCFILES}) target_link_libraries(hyprctl PUBLIC PkgConfig::hyprctl_deps) +target_include_directories(hyprctl PRIVATE "hw-protocols") + +# Hyprwire + +function(hyprprotocol protoPath protoName) + set(path ${CMAKE_CURRENT_SOURCE_DIR}/${protoPath}) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/${protoName}-client.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/${protoName}-client.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/${protoName}-spec.hpp + COMMAND hyprwire-scanner --client ${path}/${protoName}.xml + ${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/ + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + target_sources(hyprctl PRIVATE hw-protocols/${protoName}-client.cpp + hw-protocols/${protoName}-client.hpp + hw-protocols/${protoName}-spec.hpp) +endfunction() + +hyprprotocol(hw-protocols hyprpaper_core) # binary install(TARGETS hyprctl) diff --git a/hyprctl/Strings.hpp b/hyprctl/Strings.hpp deleted file mode 100644 index 67e4f992..00000000 --- a/hyprctl/Strings.hpp +++ /dev/null @@ -1,186 +0,0 @@ -#pragma once - -#include - -const std::string_view USAGE = R"#(usage: hyprctl [flags] [args...|--help] - -commands: - activewindow → Gets the active window name and its properties - activeworkspace → Gets the active workspace and its properties - animations → Gets the current config'd info about animations - and beziers - binds → Lists all registered binds - clients → Lists all windows with their properties - configerrors → Lists all current config parsing errors - cursorpos → Gets the current cursor position in global layout - coordinates - decorations → Lists all decorations and their info - devices → Lists all connected keyboards and mice - dismissnotify [amount] → Dismisses all or up to AMOUNT notifications - dispatch [args] → Issue a dispatch to call a keybind - dispatcher with arguments - getoption