Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on glaze #9067

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .github/actions/setup_base/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ runs:
librsvg \
re2

- name: Get glaze
shell: bash
run: |
git clone https://github.com/stephenberry/glaze.git
cd glaze
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 hyprwayland-scanner-git
shell: bash
run: |
Expand Down
3 changes: 2 additions & 1 deletion hyprctl/Strings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ const std::string_view PLUGIN_HELP = R"#(usage: hyprctl [flags] plugin <request>
requests:
load <path> → Loads a plugin. Path must be absolute
unload <path> → Unloads a plugin. Path must be absolute
list → Lists all loaded plugins
list [-t] → Lists all loaded plugins

flags:
-t → Terse output mode
See 'hyprctl --help')#";

const std::string_view SETPROP_HELP = R"#(usage: hyprctl [flags] setprop <regex> <property> <value> [lock]
Expand Down
2 changes: 2 additions & 0 deletions hyprctl/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ int main(int argc, char** argv) {
if (ARGS[i] == "-j" && !fullArgs.contains("j")) {
fullArgs += "j";
json = true;
} else if (ARGS[i] == "-t" && !fullArgs.contains("t")) {
fullArgs += "t";
} else if (ARGS[i] == "-r" && !fullArgs.contains("r")) {
fullArgs += "r";
} else if (ARGS[i] == "-a" && !fullArgs.contains("a")) {
Expand Down
16 changes: 1 addition & 15 deletions hyprpm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,9 @@ set(CMAKE_CXX_STANDARD 23)

pkg_check_modules(hyprpm_deps REQUIRED IMPORTED_TARGET tomlplusplus hyprutils>=0.2.4)

find_package(glaze QUIET)
if (NOT glaze_FOUND)
set(GLAZE_VERSION v4.2.3)
message(STATUS "glaze dependency not found, retrieving ${GLAZE_VERSION} with FetchContent")
include(FetchContent)
FetchContent_Declare(
glaze
GIT_REPOSITORY https://github.com/stephenberry/glaze.git
GIT_TAG ${GLAZE_VERSION}
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(glaze)
endif()

add_executable(hyprpm ${SRCFILES})

target_link_libraries(hyprpm PUBLIC PkgConfig::hyprpm_deps glaze::glaze)
target_link_libraries(hyprpm PUBLIC PkgConfig::hyprpm_deps)

# binary
install(TARGETS hyprpm)
Expand Down
21 changes: 9 additions & 12 deletions hyprpm/src/core/PluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <unistd.h>

#include <toml++/toml.hpp>
#include <glaze/glaze.hpp>

#include <hyprutils/string/String.hpp>
#include <hyprutils/os/Process.hpp>
Expand Down Expand Up @@ -792,21 +791,19 @@ ePluginLoadStateReturn CPluginManager::ensurePluginsLoadState(bool forceReload)
std::println(stderr, "PluginManager: no $HOME or $HYPRLAND_INSTANCE_SIGNATURE");
return LOADSTATE_FAIL;
}
const auto HYPRPMPATH = DataState::getDataStatePath();

const auto json = glz::read_json<glz::json_t::array_t>(execAndGet("hyprctl plugins list -j"));
if (!json) {
std::println(stderr, "PluginManager: couldn't parse hyprctl output");
return LOADSTATE_FAIL;
}
const auto HYPRPMPATH = DataState::getDataStatePath();

std::vector<std::string> loadedPlugins;
for (const auto& plugin : json.value()) {
if (!plugin.is_object() || !plugin.contains("name")) {
std::println(stderr, "PluginManager: couldn't parse plugin object");
const auto pluginLines = execAndGet("hyprctl plugins list -t");
std::istringstream pluginStream(pluginLines);
std::string pluginLine;
while (std::getline(pluginStream, pluginLine)) {
if (pluginLine == "error") {
std::println(stderr, "PluginManager: couldn't parse hyprctl output");
return LOADSTATE_FAIL;
}
loadedPlugins.emplace_back(plugin["name"].get<std::string>());
if (pluginLine != "")
loadedPlugins.emplace_back(pluginLine);
}

std::println("{}", successString("Ensuring plugin load state"));
Expand Down
1 change: 0 additions & 1 deletion hyprpm/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ executable(
dependency('hyprutils', version: '>= 0.1.1'),
dependency('threads'),
dependency('tomlplusplus'),
dependency('glaze', method: 'cmake'),
],
install: true,
)
Expand Down
4 changes: 0 additions & 4 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
pkg-config,
pkgconf,
makeWrapper,
cmake,
meson,
ninja,
aquamarine,
binutils,
cairo,
git,
glaze,
hyprcursor,
hyprgraphics,
hyprland-protocols,
Expand Down Expand Up @@ -104,7 +102,6 @@ in
makeWrapper
meson
ninja
cmake # needed for glaze
pkg-config
];

Expand All @@ -119,7 +116,6 @@ in
aquamarine
cairo
git
glaze
hyprcursor
hyprgraphics
hyprland-protocols
Expand Down
3 changes: 2 additions & 1 deletion src/SharedDefs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ struct SCallbackInfo {

enum eHyprCtlOutputFormat : uint8_t {
FORMAT_NORMAL = 0,
FORMAT_JSON
FORMAT_JSON,
FORMAT_TERSE
};

struct SHyprCtlCommand {
Expand Down
8 changes: 7 additions & 1 deletion src/debug/HyprCtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,10 @@ static std::string dispatchPlugin(eHyprCtlOutputFormat format, std::string reque
}
trimTrailingComma(result);
result += "]";
} else if (format == eHyprCtlOutputFormat::FORMAT_TERSE) {
for (auto const& p : PLUGINS) {
result += std::format("{}\n", p->name);
}
} else {
if (PLUGINS.size() == 0)
return "no plugins loaded";
Expand Down Expand Up @@ -1718,6 +1722,8 @@ std::string CHyprCtl::getReply(std::string request) {

if (c == 'j')
format = eHyprCtlOutputFormat::FORMAT_JSON;
else if (c == 't')
format = eHyprCtlOutputFormat::FORMAT_TERSE;
else if (c == 'r')
reloadAll = true;
else if (c == 'a')
Expand Down Expand Up @@ -1754,7 +1760,7 @@ std::string CHyprCtl::getReply(std::string request) {
}
}

if (result.empty())
if (result.empty() && format != eHyprCtlOutputFormat::FORMAT_TERSE)
return "unknown request";

if (reloadAll) {
Expand Down
Loading