From 6a0999e35945133165f0762568e14b0ee7bb1f16 Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Tue, 16 Jul 2024 22:51:01 +0300 Subject: [PATCH] config: use hyprutils helper CMake: add version, add hyprutils --- CMakeLists.txt | 3 ++- src/config/ConfigManager.cpp | 12 +++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bddd18d..b8746fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.4) project(hyprpaper DESCRIPTION "A blazing fast wayland wallpaper utility" + VERSION 0.7.0 ) set(CMAKE_MESSAGE_LOG_LEVEL "STATUS") @@ -71,7 +72,7 @@ add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value -Wno-m find_package(Threads REQUIRED) find_package(PkgConfig REQUIRED) -pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols cairo pango pangocairo libjpeg libwebp hyprlang>=0.2.0) +pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols cairo pango pangocairo libjpeg libwebp hyprlang>=0.2.0 hyprutils>=0.2.0) file(GLOB_RECURSE SRCFILES "src/*.cpp") diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 86c3129..a407e57 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -1,5 +1,6 @@ #include "ConfigManager.hpp" #include "../Hyprpaper.hpp" +#include static Hyprlang::CParseResult handleWallpaper(const char* C, const char* V) { const std::string COMMAND = C; @@ -196,14 +197,11 @@ std::string CConfigManager::getMainConfigPath() { if (!g_pHyprpaper->m_szExplicitConfigPath.empty()) return g_pHyprpaper->m_szExplicitConfigPath; - static const char* xdgConfigHome = getenv("XDG_CONFIG_HOME"); - std::string configPath; - if (!xdgConfigHome) - configPath = getenv("HOME") + std::string("/.config"); + static const auto paths = Hyprutils::Path::findConfig("hyprpaper"); + if (paths.first.has_value()) + return paths.first.value(); else - configPath = xdgConfigHome; - - return configPath + "/hypr/hyprpaper.conf"; + throw std::runtime_error("Could not find config in HOME, XDG_CONFIG_HOME, XDG_CONFIG_DIRS or /etc/hypr."); } // trim from both ends