mirror of
https://github.com/hyprwm/hyprcursor.git
synced 2024-12-22 10:19:48 +01:00
lib: Use XDG_DATA_DIRS to query themes (#58)
* lib: use XDG_DATA_DIRS to search themes * lib: fix some stylistic errors * lib: more stylistic errors fixed
This commit is contained in:
parent
4493a972b4
commit
5a95d8512b
3 changed files with 18 additions and 21 deletions
|
@ -2,6 +2,7 @@
|
||||||
#include "internalSharedTypes.hpp"
|
#include "internalSharedTypes.hpp"
|
||||||
#include "internalDefines.hpp"
|
#include "internalDefines.hpp"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <cstdio>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <zip.h>
|
#include <zip.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -15,11 +16,25 @@
|
||||||
|
|
||||||
using namespace Hyprcursor;
|
using namespace Hyprcursor;
|
||||||
|
|
||||||
// directories for lookup
|
static std::vector<std::string> getSystemThemeDirs() {
|
||||||
constexpr const std::array<const char*, 1> systemThemeDirs = {"/usr/share/icons"};
|
const auto 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
|
||||||
|
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"};
|
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");
|
const auto ENV = getenv("HYPRCURSOR_THEME");
|
||||||
if (!ENV) {
|
if (!ENV) {
|
||||||
|
@ -728,7 +743,7 @@ std::optional<std::string> CHyprcursorImplementation::loadTheme() {
|
||||||
IMAGE->cairoSurface = cairo_image_surface_create_from_png_stream(::readPNG, IMAGE);
|
IMAGE->cairoSurface = cairo_image_surface_create_from_png_stream(::readPNG, IMAGE);
|
||||||
|
|
||||||
if (const auto STATUS = cairo_surface_status(IMAGE->cairoSurface); STATUS != CAIRO_STATUS_SUCCESS) {
|
if (const auto STATUS = cairo_surface_status(IMAGE->cairoSurface); STATUS != CAIRO_STATUS_SUCCESS) {
|
||||||
delete[](char*) IMAGE->data;
|
delete[] (char*)IMAGE->data;
|
||||||
IMAGE->data = nullptr;
|
IMAGE->data = nullptr;
|
||||||
return "Failed reading cairoSurface, status " + std::to_string((int)STATUS);
|
return "Failed reading cairoSurface, status " + std::to_string((int)STATUS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,6 @@ stdenv.mkDerivation {
|
||||||
inherit version;
|
inherit version;
|
||||||
src = ../.;
|
src = ../.;
|
||||||
|
|
||||||
patches = [
|
|
||||||
# adds /run/current-system/sw/share/icons to the icon lookup directories
|
|
||||||
./dirs.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
cmake
|
cmake
|
||||||
pkg-config
|
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…
Reference in a new issue