aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVaxry <[email protected]>2023-12-06 22:23:10 +0000
committerVaxry <[email protected]>2023-12-06 23:31:04 +0000
commitea304efd962703232463ff8a594234a8c55bd452 (patch)
tree9ae00442a923d1b6559f5648c99dfe2fc3bd69d5
parent657cee2b98f7b085a384aba41d24bfd4177999f8 (diff)
downloadHyprland-ea304efd962703232463ff8a594234a8c55bd452.tar.gz
Hyprland-ea304efd962703232463ff8a594234a8c55bd452.zip
fixes
-rw-r--r--hyprpm/src/core/DataState.cpp18
-rw-r--r--hyprpm/src/core/DataState.hpp4
-rw-r--r--hyprpm/src/core/PluginManager.cpp24
3 files changed, 40 insertions, 6 deletions
diff --git a/hyprpm/src/core/DataState.cpp b/hyprpm/src/core/DataState.cpp
index af888898..d95f10bb 100644
--- a/hyprpm/src/core/DataState.cpp
+++ b/hyprpm/src/core/DataState.cpp
@@ -118,6 +118,7 @@ void DataState::updateGlobalState(const SGlobalState& state) {
auto DATA = toml::table{
{"state", toml::table{
{"hash", state.headersHashCompiled},
+ {"dont_warn_install", state.dontWarnInstall}
}}
};
// clang-format on
@@ -127,6 +128,23 @@ void DataState::updateGlobalState(const SGlobalState& state) {
ofs.close();
}
+SGlobalState DataState::getGlobalState() {
+ ensureStateStoreExists();
+
+ const auto PATH = getDataStatePath();
+
+ if (!std::filesystem::exists(PATH + "/state.toml"))
+ return SGlobalState{};
+
+ auto DATA = toml::parse_file(PATH + "/state.toml");
+
+ SGlobalState state;
+ state.headersHashCompiled = DATA["state"]["hash"].value_or("");
+ state.dontWarnInstall = DATA["state"]["dont_warn_install"].value_or(false);
+
+ return state;
+}
+
std::vector<SPluginRepository> DataState::getAllRepositories() {
ensureStateStoreExists();
diff --git a/hyprpm/src/core/DataState.hpp b/hyprpm/src/core/DataState.hpp
index cd609dba..ac81dae1 100644
--- a/hyprpm/src/core/DataState.hpp
+++ b/hyprpm/src/core/DataState.hpp
@@ -4,7 +4,8 @@
#include "Plugin.hpp"
struct SGlobalState {
- std::string headersHashCompiled;
+ std::string headersHashCompiled = "";
+ bool dontWarnInstall = false;
};
namespace DataState {
@@ -14,6 +15,7 @@ namespace DataState {
void removePluginRepo(const std::string& urlOrName);
bool pluginRepoExists(const std::string& urlOrName);
void updateGlobalState(const SGlobalState& state);
+ SGlobalState getGlobalState();
bool setPluginEnabled(const std::string& name, bool enabled);
std::vector<SPluginRepository> getAllRepositories();
}; \ No newline at end of file
diff --git a/hyprpm/src/core/PluginManager.cpp b/hyprpm/src/core/PluginManager.cpp
index b404e216..00391f5d 100644
--- a/hyprpm/src/core/PluginManager.cpp
+++ b/hyprpm/src/core/PluginManager.cpp
@@ -34,6 +34,15 @@ bool CPluginManager::addNewPluginRepo(const std::string& url) {
return false;
}
+ auto GLOBALSTATE = DataState::getGlobalState();
+ if (!GLOBALSTATE.dontWarnInstall) {
+ std::cout << Colors::YELLOW << "!" << Colors::RED << " Disclaimer:\n " << Colors::RESET
+ << "plugins, especially not official, have no guarantee of stability, availablity or security.\n Run them at your own risk.\n "
+ << "This message will not appear again.\n";
+ GLOBALSTATE.dontWarnInstall = true;
+ DataState::updateGlobalState(GLOBALSTATE);
+ }
+
std::cout << Colors::GREEN << "✔" << Colors::RESET << Colors::RED << " adding a new plugin repository " << Colors::RESET << "from " << url << "\n " << Colors::RED
<< "MAKE SURE" << Colors::RESET << " that you trust the authors. " << Colors::RED << "DO NOT" << Colors::RESET
<< " install random plugins without verifying the code and author.\n "
@@ -284,7 +293,9 @@ bool CPluginManager::updateHeaders() {
if (headersValid() == HEADERS_OK) {
std::cout << "\n" << std::string{Colors::GREEN} + "✔" + Colors::RESET + " Your headers are already up-to-date.\n";
- DataState::updateGlobalState(SGlobalState{hlcommit});
+ auto GLOBALSTATE = DataState::getGlobalState();
+ GLOBALSTATE.headersHashCompiled = hlcommit;
+ DataState::updateGlobalState(GLOBALSTATE);
return true;
}
@@ -313,7 +324,7 @@ bool CPluginManager::updateHeaders() {
progress.m_szCurrentMessage = "Checking out sources";
progress.print();
- ret = execAndGet("cd /tmp/hyprpm/hyprland && git checkout " + hlbranch + " && git submodule update --init && git reset --hard --recurse-submodules " + hlcommit);
+ ret = execAndGet("cd /tmp/hyprpm/hyprland && git checkout " + hlbranch + " 2>&1 && git submodule update --init 2>&1 && git reset --hard --recurse-submodules " + hlcommit);
progress.printMessageAbove(std::string{Colors::GREEN} + "✔" + Colors::RESET + " checked out to running ver");
progress.m_iSteps = 3;
@@ -338,17 +349,20 @@ bool CPluginManager::updateHeaders() {
// remove build files
std::filesystem::remove_all("/tmp/hyprpm/hyprland");
- if (headersValid() == HEADERS_OK) {
+ auto HEADERSVALID = headersValid();
+ if (HEADERSVALID == HEADERS_OK) {
progress.printMessageAbove(std::string{Colors::GREEN} + "✔" + Colors::RESET + " installed headers");
progress.m_iSteps = 5;
progress.m_szCurrentMessage = "Done!";
progress.print();
- DataState::updateGlobalState(SGlobalState{hlcommit});
+ auto GLOBALSTATE = DataState::getGlobalState();
+ GLOBALSTATE.headersHashCompiled = hlcommit;
+ DataState::updateGlobalState(GLOBALSTATE);
std::cout << "\n";
} else {
- progress.printMessageAbove(std::string{Colors::RED} + "✖" + Colors::RESET + " failed to install headers");
+ progress.printMessageAbove(std::string{Colors::RED} + "✖" + Colors::RESET + " failed to install headers with error code " + std::to_string((int)HEADERSVALID));
progress.m_iSteps = 5;
progress.m_szCurrentMessage = "Failed";
progress.print();