mirror of
https://github.com/hyprwm/hypridle.git
synced 2024-11-16 23:25:58 +01:00
config: use hyprutils helper
This commit is contained in:
parent
fb51c1413d
commit
cf3a09f3cc
2 changed files with 9 additions and 12 deletions
|
@ -33,7 +33,7 @@ message(STATUS "Checking deps...")
|
||||||
|
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols hyprlang>=0.4.0 sdbus-c++)
|
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols hyprlang>=0.4.0 hyprutils>=0.2.0 sdbus-c++)
|
||||||
|
|
||||||
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
|
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
|
||||||
add_executable(hypridle ${SRCFILES})
|
add_executable(hypridle ${SRCFILES})
|
||||||
|
|
|
@ -1,20 +1,17 @@
|
||||||
#include "ConfigManager.hpp"
|
#include "ConfigManager.hpp"
|
||||||
|
#include <hyprutils/path/Path.hpp>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
static std::string getConfigDir() {
|
|
||||||
static const char* xdgConfigHome = getenv("XDG_CONFIG_HOME");
|
|
||||||
|
|
||||||
if (xdgConfigHome && std::filesystem::path(xdgConfigHome).is_absolute())
|
|
||||||
return xdgConfigHome;
|
|
||||||
|
|
||||||
return getenv("HOME") + std::string("/.config");
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string getMainConfigPath() {
|
static std::string getMainConfigPath() {
|
||||||
return getConfigDir() + "/hypr/hypridle.conf";
|
static const auto paths = Hyprutils::Path::findConfig("hypridle");
|
||||||
|
if (paths.first.has_value())
|
||||||
|
return paths.first.value();
|
||||||
|
else
|
||||||
|
throw std::runtime_error("Could not find config in HOME, XDG_CONFIG_HOME, XDG_CONFIG_DIRS or /etc/hypr.");
|
||||||
}
|
}
|
||||||
|
|
||||||
CConfigManager::CConfigManager(std::string configPath) : m_config(configPath.empty() ? getMainConfigPath().c_str() : configPath.c_str(), Hyprlang::SConfigOptions{.throwAllErrors = true, .allowMissingConfig = false}) {
|
CConfigManager::CConfigManager(std::string configPath) :
|
||||||
|
m_config(configPath.empty() ? getMainConfigPath().c_str() : configPath.c_str(), Hyprlang::SConfigOptions{.throwAllErrors = true, .allowMissingConfig = false}) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue