config: use hyprutils helper

CMake: add version, add hyprutils
This commit is contained in:
Mihai Fufezan 2024-07-16 22:51:01 +03:00
parent 13fcdd79ef
commit 6a0999e359
Signed by: fufexan
SSH key fingerprint: SHA256:SdnKmEpJrDu1+2UO1QpB/Eg4HKcdDi6n+xSRqFNJVpg
2 changed files with 7 additions and 8 deletions

View file

@ -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")

View file

@ -1,5 +1,6 @@
#include "ConfigManager.hpp"
#include "../Hyprpaper.hpp"
#include <hyprutils/path/Path.hpp>
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