mirror of
https://github.com/hyprwm/hyprcursor.git
synced 2025-12-20 04:00:02 +01:00
lib: use XDG_DATA_DIRS to search themes
This commit is contained in:
parent
4493a972b4
commit
fb40ac08f8
3 changed files with 19 additions and 23 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include "internalSharedTypes.hpp"
|
||||
#include "internalDefines.hpp"
|
||||
#include <array>
|
||||
#include <cstdio>
|
||||
#include <filesystem>
|
||||
#include <zip.h>
|
||||
#include <cstring>
|
||||
|
|
@ -15,12 +16,25 @@
|
|||
|
||||
using namespace Hyprcursor;
|
||||
|
||||
// directories for lookup
|
||||
constexpr const std::array<const char*, 1> systemThemeDirs = {"/usr/share/icons"};
|
||||
static std::vector<std::string> getSystemThemeDirs() {
|
||||
char* envXdgData = std::getenv("XDG_DATA_DIRS");
|
||||
std::vector<std::string> result;
|
||||
if (envXdgData) {
|
||||
std::stringstream envXdgStream(envXdgData);
|
||||
std::string tmpStr;
|
||||
while (getline(envXdgStream, tmpStr, ':')) {
|
||||
result.push_back((tmpStr + "/icons"));
|
||||
}
|
||||
} else {
|
||||
std::vector<std::string> result = {"/usr/share/icons"};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const std::vector<std::string> systemThemeDirs = getSystemThemeDirs();
|
||||
constexpr const std::array<const char*, 2> userThemeDirs = {"/.local/share/icons", "/.icons"};
|
||||
|
||||
//
|
||||
static std::string themeNameFromEnv(PHYPRCURSORLOGFUNC logfn) {
|
||||
static std::string themeNameFromEnv(PHYPRCURSORLOGFUNC logfn) {
|
||||
const auto ENV = getenv("HYPRCURSOR_THEME");
|
||||
if (!ENV) {
|
||||
Debug::log(HC_LOG_INFO, logfn, "themeNameFromEnv: env unset");
|
||||
|
|
@ -728,7 +742,7 @@ std::optional<std::string> CHyprcursorImplementation::loadTheme() {
|
|||
IMAGE->cairoSurface = cairo_image_surface_create_from_png_stream(::readPNG, IMAGE);
|
||||
|
||||
if (const auto STATUS = cairo_surface_status(IMAGE->cairoSurface); STATUS != CAIRO_STATUS_SUCCESS) {
|
||||
delete[](char*) IMAGE->data;
|
||||
delete[] (char*)IMAGE->data;
|
||||
IMAGE->data = nullptr;
|
||||
return "Failed reading cairoSurface, status " + std::to_string((int)STATUS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,11 +15,6 @@ stdenv.mkDerivation {
|
|||
inherit version;
|
||||
src = ../.;
|
||||
|
||||
patches = [
|
||||
# adds /run/current-system/sw/share/icons to the icon lookup directories
|
||||
./dirs.patch
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
pkg-config
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
diff --git a/libhyprcursor/hyprcursor.cpp b/libhyprcursor/hyprcursor.cpp
|
||||
index 304ab9f..1f7e95d 100644
|
||||
--- a/libhyprcursor/hyprcursor.cpp
|
||||
+++ b/libhyprcursor/hyprcursor.cpp
|
||||
@@ -14,7 +14,7 @@
|
||||
using namespace Hyprcursor;
|
||||
|
||||
// directories for lookup
|
||||
-constexpr const std::array<const char*, 1> systemThemeDirs = {"/usr/share/icons"};
|
||||
+constexpr const std::array<const char*, 2> systemThemeDirs = {"/usr/share/icons", "/run/current-system/sw/share/icons"};
|
||||
constexpr const std::array<const char*, 2> userThemeDirs = {"/.local/share/icons", "/.icons"};
|
||||
|
||||
//
|
||||
Loading…
Add table
Reference in a new issue