Config: use hyprutils helper (#422)

* flake.lock: update

* gitignore: add CMake residual files

* config: use hyprutils helper

* CMake: update required hyprutils version
This commit is contained in:
Mihai Fufezan 2024-07-16 23:35:48 +03:00 committed by GitHub
parent 69d37d2663
commit a3d8a2c128
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 26 deletions

6
.gitignore vendored
View File

@ -1,7 +1,11 @@
.cache
**/.cache
.direnv
.envrc
.vscode/
CMakeCache.txt
CMakeFiles/
Makefile
cmake_install.cmake
build/
compile_commands.json
protocols/*.c

View File

@ -39,7 +39,7 @@ message(STATUS "Checking deps...")
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(OpenGL REQUIRED)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols wayland-egl hyprlang>=0.4.0 egl opengl xkbcommon libjpeg libwebp libmagic cairo pangocairo libdrm gbm hyprutils>=0.1.1)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols wayland-egl hyprlang>=0.4.0 egl opengl xkbcommon libjpeg libwebp libmagic cairo pangocairo libdrm gbm hyprutils>=0.2.0)
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
add_executable(hyprlock ${SRCFILES})

View File

@ -13,11 +13,11 @@
]
},
"locked": {
"lastModified": 1717881852,
"narHash": "sha256-XeeVoKHQgfKuXoP6q90sUqKyl7EYy3ol2dVZGM+Jj94=",
"lastModified": 1720381373,
"narHash": "sha256-lyC/EZdHULsaAKVryK11lgHY9u6pXr7qR4irnxNWC7k=",
"owner": "hyprwm",
"repo": "hyprlang",
"rev": "ec6938c66253429192274d612912649a0cfe4d28",
"rev": "5df0174fd09de4ac5475233d65ffc703e89b82eb",
"type": "github"
},
"original": {
@ -36,11 +36,11 @@
]
},
"locked": {
"lastModified": 1717881334,
"narHash": "sha256-a0inRgJhPL6v9v7RPM/rx1kbXdfe3xJA1c9z0ZkYnh4=",
"lastModified": 1721071737,
"narHash": "sha256-qmC9jGfbE4+EIBbbSAkrfR/p49wShjpv4/KztgE/P54=",
"owner": "hyprwm",
"repo": "hyprutils",
"rev": "0693f9398ab693d89c9a0aa3b3d062dd61b7a60e",
"rev": "eb1ceff2b87f6820789249f63faa8e9dcb54d05f",
"type": "github"
},
"original": {
@ -51,11 +51,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1717602782,
"narHash": "sha256-pL9jeus5QpX5R+9rsp3hhZ+uplVHscNJh8n8VpqscM0=",
"lastModified": 1720957393,
"narHash": "sha256-oedh2RwpjEa+TNxhg5Je9Ch6d3W1NKi7DbRO1ziHemA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e8057b67ebf307f01bdcc8fba94d94f75039d1f6",
"rev": "693bc46d169f5af9c992095736e82c3488bf7dbb",
"type": "github"
},
"original": {

View File

@ -1,6 +1,7 @@
#include "ConfigManager.hpp"
#include "../helpers/MiscFunctions.hpp"
#include "src/helpers/Log.hpp"
#include <hyprutils/path/Path.hpp>
#include <filesystem>
#include <glob.h>
#include <cstring>
@ -18,22 +19,12 @@ static Hyprlang::CParseResult handleSource(const char* c, const char* v) {
return result;
}
static std::string getConfigDir() {
static const char* xdgConfigHome = getenv("XDG_CONFIG_HOME");
if (xdgConfigHome && std::filesystem::path(xdgConfigHome).is_absolute())
return xdgConfigHome;
static const char* home = getenv("HOME");
if (!home)
throw std::runtime_error("Neither HOME nor XDG_CONFIG_HOME is set in the environment. Cannot determine config directory.");
return home + std::string("/.config");
}
static std::string getMainConfigPath() {
return getConfigDir() + "/hypr/hyprlock.conf";
static const auto paths = Hyprutils::Path::findConfig("hyprlock");
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) :