diff options
| author | Gabriel Ford <gabe@fordltc.net> | 2024-05-25 20:46:07 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-25 22:46:07 +0200 |
| commit | 553232a3e4c112c8511309e6b685cb614895e714 (patch) | |
| tree | 18bfc535208785e0577fd410b386b7ffbdf561bb /src | |
| parent | addd3e7f1aeb670dd91d26005aaeccce3efb1ae7 (diff) | |
hyprctl: Add Config Flag to `hyprctl systeminfo` (#6160)
Diffstat (limited to 'src')
| -rw-r--r-- | src/config/ConfigManager.cpp | 19 | ||||
| -rw-r--r-- | src/config/ConfigManager.hpp | 1 | ||||
| -rw-r--r-- | src/debug/HyprCtl.cpp | 9 | ||||
| -rw-r--r-- | src/debug/HyprCtl.hpp | 5 |
4 files changed, 32 insertions, 2 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index fd70da77..f65b5abb 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -633,6 +633,25 @@ std::string CConfigManager::getMainConfigPath() { return getConfigDir() + "/hypr/" + (ISDEBUG ? "hyprlandd.conf" : "hyprland.conf"); } +const std::string CConfigManager::getConfigString() { + std::string configString; + std::string currFileContent; + + for (auto path : configPaths) { + std::ifstream configFile(path); + configString += ("\n\nConfig File: " + path + ": "); + if (!configFile.is_open()) { + Debug::log(LOG, "Config file not readable/found!"); + configString += "Read Failed\n"; + continue; + } + configString += "Read Succeeded\n"; + currFileContent.assign(std::istreambuf_iterator<char>(configFile), std::istreambuf_iterator<char>()); + configString.append(currFileContent); + } + return configString; +} + std::string CConfigManager::getErrors() { return m_szConfigErrors; } diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 45b100ee..ca22904d 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -103,6 +103,7 @@ class CConfigManager { void onPluginLoadUnload(const std::string& name, bool load); static std::string getConfigDir(); static std::string getMainConfigPath(); + const std::string getConfigString(); SMonitorRule getMonitorRuleFor(const CMonitor&); SWorkspaceRule getWorkspaceRuleFor(PHLWORKSPACE workspace); diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index dc5fa742..1faea41c 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -23,6 +23,7 @@ #include "../devices/IKeyboard.hpp" #include "../devices/ITouch.hpp" #include "../devices/Tablet.hpp" +#include "config/ConfigManager.hpp" static void trimTrailingComma(std::string& str) { if (!str.empty() && str.back() == ',') @@ -897,6 +898,12 @@ std::string systemInfoRequest(eHyprCtlOutputFormat format, std::string request) result += std::format(" {} by {} ver {}\n", pl->name, pl->author, pl->version); } + if (g_pHyprCtl->m_sCurrentRequestParams.sysInfoConfig) { + result += "\n======Config-Start======\n"; + result += g_pConfigManager->getConfigString(); + result += "\n======Config-End========\n"; + } + return result; } @@ -1640,6 +1647,8 @@ std::string CHyprCtl::getReply(std::string request) { reloadAll = true; else if (c == 'a') m_sCurrentRequestParams.all = true; + else if (c == 'c') + m_sCurrentRequestParams.sysInfoConfig = true; } if (sepIndex < request.size()) diff --git a/src/debug/HyprCtl.hpp b/src/debug/HyprCtl.hpp index ebcb87cf..b48ea26a 100644 --- a/src/debug/HyprCtl.hpp +++ b/src/debug/HyprCtl.hpp @@ -17,7 +17,8 @@ class CHyprCtl { int m_iSocketFD = -1; struct { - bool all = false; + bool all = false; + bool sysInfoConfig = false; } m_sCurrentRequestParams; private: @@ -26,4 +27,4 @@ class CHyprCtl { std::vector<SP<SHyprCtlCommand>> m_vCommands; }; -inline std::unique_ptr<CHyprCtl> g_pHyprCtl;
\ No newline at end of file +inline std::unique_ptr<CHyprCtl> g_pHyprCtl; |
