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
Changes from 1 commit
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
Next Next commit
hyprctl plugin list: add -t option so we don't need glaze
earboxer committed Jan 17, 2025
commit 42bb8bc1d4bc5414444636a00f35d55cfb9a329e
2 changes: 2 additions & 0 deletions hyprctl/main.cpp
Original file line number Diff line number Diff line change
@@ -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")) {
21 changes: 9 additions & 12 deletions hyprpm/src/core/PluginManager.cpp
Original file line number Diff line number Diff line change
@@ -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>
@@ -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"));
3 changes: 2 additions & 1 deletion src/SharedDefs.hpp
Original file line number Diff line number Diff line change
@@ -43,7 +43,8 @@ struct SCallbackInfo {

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

struct SHyprCtlCommand {
8 changes: 7 additions & 1 deletion src/debug/HyprCtl.cpp
Original file line number Diff line number Diff line change
@@ -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";
@@ -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')
@@ -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) {