summaryrefslogtreecommitdiff
path: root/hyprpm/src/core/PluginManager.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2023-12-13 02:32:57 +0000
committerVaxry <vaxry@vaxry.net>2023-12-13 02:33:07 +0000
commit4190b967186e50d00ea3dc636e9f3ec40639dd03 (patch)
tree97d8b10614992b97879b2d490fe61686d8c2f43a /hyprpm/src/core/PluginManager.cpp
parentd9bc210285c1971afd9abe9fbe89a5a14c8df2a7 (diff)
hyprpm: add duplicate header error and log more verbose in install fails
Diffstat (limited to 'hyprpm/src/core/PluginManager.cpp')
-rw-r--r--hyprpm/src/core/PluginManager.cpp33
1 files changed, 24 insertions, 9 deletions
diff --git a/hyprpm/src/core/PluginManager.cpp b/hyprpm/src/core/PluginManager.cpp
index e6e0a750..c69533ee 100644
--- a/hyprpm/src/core/PluginManager.cpp
+++ b/hyprpm/src/core/PluginManager.cpp
@@ -157,15 +157,7 @@ bool CPluginManager::addNewPluginRepo(const std::string& url) {
const auto HEADERSSTATUS = headersValid();
if (HEADERSSTATUS != HEADERS_OK) {
-
- switch (HEADERSSTATUS) {
- case HEADERS_CORRUPTED: std::cerr << "\n" << Colors::RED << "✖" << Colors::RESET << " Headers corrupted. Please run hyprpm update to fix those.\n"; break;
- case HEADERS_MISMATCHED: std::cerr << "\n" << Colors::RED << "✖" << Colors::RESET << " Headers version mismatch. Please run hyprpm update to fix those.\n"; break;
- case HEADERS_NOT_HYPRLAND: std::cerr << "\n" << Colors::RED << "✖" << Colors::RESET << " It doesn't seem you are running on hyprland.\n"; break;
- case HEADERS_MISSING: std::cerr << "\n" << Colors::RED << "✖" << Colors::RESET << " Headers missing. Please run hyprpm update to fix those.\n"; break;
- default: break;
- }
-
+ std::cerr << "\n" << headerError(HEADERSSTATUS);
return false;
}
@@ -285,6 +277,10 @@ eHeadersErrors CPluginManager::headersValid() {
if (!ifs.good())
return HEADERS_CORRUPTED;
+ if ((std::filesystem::exists("/usr/include/hyprland/src/version.h") && verHeader != "/usr/include/hyprland/src/version.h") ||
+ (std::filesystem::exists("/usr/local/include/hyprland/src/version.h") && verHeader != "/usr/local/include/hyprland/src/version.h"))
+ return HEADERS_DUPLICATED;
+
std::string verHeaderContent((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
ifs.close();
@@ -395,6 +391,8 @@ bool CPluginManager::updateHeaders() {
std::cout << "\n";
+ std::cerr << "\n" << headerError(HEADERSVALID);
+
return false;
}
@@ -687,4 +685,21 @@ void CPluginManager::listAllPlugins() {
void CPluginManager::notify(const eNotifyIcons icon, uint32_t color, int durationMs, const std::string& message) {
execAndGet("hyprctl notify " + std::to_string((int)icon) + " " + std::to_string(durationMs) + " " + std::to_string(color) + " " + message);
+}
+
+std::string CPluginManager::headerError(const eHeadersErrors err) {
+ switch (err) {
+ case HEADERS_CORRUPTED: return std::string{Colors::RED} + "✖" + Colors::RESET + " Headers corrupted. Please run hyprpm update to fix those.\n";
+ case HEADERS_MISMATCHED: return std::string{Colors::RED} + "✖" + Colors::RESET + " Headers version mismatch. Please run hyprpm update to fix those.\n";
+ case HEADERS_NOT_HYPRLAND: return std::string{Colors::RED} + "✖" + Colors::RESET + " It doesn't seem you are running on hyprland.\n";
+ case HEADERS_MISSING: return std::string{Colors::RED} + "✖" + Colors::RESET + " Headers missing. Please run hyprpm update to fix those.\n";
+ case HEADERS_DUPLICATED: {
+ return std::string{Colors::RED} + "✖" + Colors::RESET + " Headers duplicated!!! This is a very bad sign.\n" +
+ " This could be due to e.g. installing hyprland manually while a system package of hyprland is also installed.\n" +
+ " If the above doesn't apply, check your /usr/include and /usr/local/include directories\n and remove all the hyprland headers.\n";
+ }
+ default: break;
+ }
+
+ return std::string{Colors::RED} + "✖" + Colors::RESET + " Unknown header error. Please run hyprpm update to fix those.\n";
} \ No newline at end of file