From 5a1454ab310bf4abebf7a93c35f5b29d462938f6 Mon Sep 17 00:00:00 2001 From: Viktar Lukashonak Date: Sat, 18 May 2024 11:28:10 +0300 Subject: [PATCH] Cava. $XDG_CONFIG_HOME validation Signed-off-by: Viktar Lukashonak --- src/modules/cava.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/cava.cpp b/src/modules/cava.cpp index 07227546..a98e5a67 100644 --- a/src/modules/cava.cpp +++ b/src/modules/cava.cpp @@ -12,7 +12,12 @@ waybar::modules::Cava::Cava(const std::string& id, const Json::Value& config) std::string strPath{config_["cava_config"].asString()}; const std::string fnd{"XDG_CONFIG_HOME"}; const std::string::size_type npos{strPath.find("$" + fnd)}; - if (npos != std::string::npos) strPath.replace(npos, fnd.length() + 1, getenv(fnd.c_str())); + if (npos != std::string::npos) { + if (const char* xdg = getenv(fnd.c_str())) + strPath.replace(npos, fnd.length() + 1, xdg); + else + spdlog::warn("Module {0}. Environment variable \"${1}\" not found", name_, fnd); + } strcpy(cfgPath, strPath.data()); } // Load cava config