Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config: use hyprutils helper #183

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
79 changes: 50 additions & 29 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 31 additions & 12 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,26 @@

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default-linux";

hyprlang.url = "github:hyprwm/hyprlang";
hyprutils = {
url = "github:hyprwm/hyprutils";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
};

systems.url = "github:nix-systems/default-linux";
hyprlang = {
url = "github:hyprwm/hyprlang";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
inputs.hyprutils.follows = "hyprutils";
};

hyprwayland-scanner = {
url = "github:hyprwm/hyprwayland-scanner";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
};
};

outputs = {
Expand All @@ -31,16 +47,19 @@
in {
overlays = {
default = self.overlays.hyprpaper;
hyprpaper = final: prev: rec {
hyprpaper = final.callPackage ./nix/default.nix {
stdenv = final.gcc13Stdenv;
version = "0.pre" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
commit = self.rev or "";
inherit (final.xorg) libXdmcp;
inherit (inputs.hyprlang.packages.${final.system}) hyprlang;
};
hyprpaper-debug = hyprpaper.override {debug = true;};
};
hyprpaper = lib.composeManyExtensions [
inputs.hyprlang.overlays.default
inputs.hyprutils.overlays.default
inputs.hyprwayland-scanner.overlays.default
(final: prev: rec {
hyprpaper = final.callPackage ./nix/default.nix {
stdenv = final.gcc13Stdenv;
version = "0.7.0" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
commit = self.rev or "";
};
hyprpaper-debug = hyprpaper.override {debug = true;};
})
];
};

packages = eachSystem (system: {
Expand Down
12 changes: 8 additions & 4 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
file,
fribidi,
hyprlang,
hyprutils,
hyprwayland-scanner,
libdatrie,
libGL,
libjpeg,
Expand All @@ -22,7 +24,7 @@
wayland,
wayland-protocols,
wayland-scanner,
libXdmcp,
xorg,
commit,
debug ? false,
version ? "git",
Expand All @@ -45,6 +47,7 @@ stdenv.mkDerivation {

nativeBuildInputs = [
cmake
hyprwayland-scanner
pkg-config
];

Expand All @@ -54,6 +57,7 @@ stdenv.mkDerivation {
file
fribidi
hyprlang
hyprutils
libdatrie
libGL
libjpeg
Expand All @@ -67,15 +71,15 @@ stdenv.mkDerivation {
wayland
wayland-protocols
wayland-scanner
libXdmcp
xorg.libXdmcp
util-linux
];

meta = with lib; {
homepage = "https://github.com/hyprwm/hyprpaper";
description = "A blazing fast wayland wallpaper utility with IPC controls";
homepage = "https://github.com/hyprwm/hyprpaper";
license = licenses.bsd3;
platforms = platforms.linux;
mainProgram = "hyprpaper";
platforms = platforms.linux;
};
}
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
Loading