core: move to os/Process from hyprutils

nix bump too
This commit is contained in:
Vaxry
2024-11-09 17:11:38 +00:00
parent dca75db127
commit a8ff3a452c
5 changed files with 21 additions and 28 deletions

View File

@@ -23,22 +23,19 @@
#include <toml++/toml.hpp>
#include <hyprutils/string/String.hpp>
#include <hyprutils/os/Process.hpp>
using namespace Hyprutils::String;
using namespace Hyprutils::OS;
static std::string execAndGet(std::string cmd) {
cmd += " 2>&1";
std::array<char, 128> buffer;
std::string result;
using PcloseType = int (*)(FILE*);
const std::unique_ptr<FILE, PcloseType> pipe(popen(cmd.c_str(), "r"), static_cast<PcloseType>(pclose));
if (!pipe)
return "";
result.reserve(buffer.size());
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
result += buffer.data();
}
return result;
CProcess proc("/bin/sh", {cmd});
if (!proc.runSync())
return "error";
return proc.stdOut();
}
SHyprlandVersion CPluginManager::getHyprlandVersion() {