Skip to content

Commit

Permalink
config: use hyprutils helper
Browse files Browse the repository at this point in the history
CMake: add version, add hyprutils
  • Loading branch information
fufexan committed Jul 16, 2024
1 parent 13fcdd7 commit 9b04302
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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")

Expand Down
12 changes: 5 additions & 7 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/config/ConfigManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CConfigManager {
void parse();

std::deque<std::string> m_dRequestedPreloads;
std::string getMainConfigPath();
static std::string getMainConfigPath();
std::string trimPath(std::string path);

std::unique_ptr<Hyprlang::CConfig> config;
Expand Down

0 comments on commit 9b04302

Please sign in to comment.