diff --git a/build b/build index a3946528..4ba56321 100755 --- a/build +++ b/build @@ -61,50 +61,30 @@ create_aliases() { create_hyprcursors() { local src_dir="$1" local out_dir="$2" - local theme_name="$3" local hypr_dir="$out_dir/hyprcursors" - local filename dir cursor_dir base_name symlink target theme_comment [ -d "$out_dir" ] || mkdir -p "$out_dir" [ -d "$hypr_dir" ] || mkdir -p "$hypr_dir" - for file in "$src_dir"/*.svg; do - filename=$(basename -- "$file") - - # hyprcursor doesn't care about sizes of svgs, can skip the '_24.svg' variant with no impact - if [[ "$filename" == *_24.svg ]]; then - continue - fi - - # we want to put all of the `progress_01, progress_02, etc` into the same directory of `progress` - if [[ "$filename" == *-[0-9][0-9].svg ]]; then - dir="${filename%-[0-9][0-9].svg}" - else - dir="${filename%.svg}" - fi - - cursor_dir="$hypr_dir/$dir" - [ -d "$cursor_dir" ] || mkdir -p "$cursor_dir" - cp -- "$file" "$cursor_dir" - done + hyprcursor-util -x "$src_dir" -o "$out_dir" >/dev/null +} - for config in "$CONFIG_DIR"/*.hl; do - [ -f "$config" ] || continue +compile_hyprcursors() { + local hl_dir="$1" + local out_dir="$2" + local src_dir="$3" + local theme_name="$(basename "$1" | sed 's/extracted_//')" - base_name="$(basename "$config" .hl)" - cursor_dir="$hypr_dir/$base_name" - [ -d "$cursor_dir" ] || continue - cp "$config" "$cursor_dir/meta.hl" - done + [ -d "$hl_dir" ] || return 1 + [ -d "$out_dir" ] || mkdir -p "$out_dir" - while read -r symlink target; do - cursor_dir="$out_dir/$target" - if [ -f "$cursor_dir"/meta.hl ]; then - echo "define_override = $symlink" >>"$cursor_dir"/meta.hl - fi - done <"$ALIASES" + hyprcursor-util -c "$hl_dir" -o "$out_dir" >/dev/null + # For whatever reason, hyprcursor appends "Extracted Theme" to the end so we have to work around it + mv "$out_dir/theme_Extracted Theme/hyprcursors" "$out_dir/hyprcursors" + rm -rf "$out_dir/theme_Extracted Theme" + + local theme_comment="$(grep Comment "$src_dir"/index.theme)" - theme_comment="$(grep Comment "$src_dir"/index.theme)" cat >"$out_dir"/manifest.hl <<-EOM name = ${theme_name%-cursors} description = ${theme_comment#Comment=} @@ -113,19 +93,6 @@ cursors_directory = hyprcursors EOM } -compile_hyprcursors() { - local hl_dir="$1" - local out_dir="$2" - local theme_name="$(basename "$1")" - local compile_dir="$1/../theme_${theme_name%-cursors}" - - [ -d "$hl_dir" ] || return 1 - [ -d "$out_dir" ] || mkdir -p "$out_dir" - - hyprcursor-util -c "$hl_dir" >/dev/null - cp -a "$compile_dir/." "$out_dir/" -} - SCRIPT_DIR="$(dirname "$0")" SRC_DIR="$SCRIPT_DIR/src" OUT_DIR="$SCRIPT_DIR/dist" @@ -201,12 +168,12 @@ if [[ $HYPRCURSOR == 1 ]]; then echo "[INFO] - Generating hyprcursor theme..." for accent in $ACCENTS; do theme_name="catppuccin-$FLAVOR-$accent-cursors" - theme_src_dir="$SRC_DIR/$theme_name" - theme_hl_dir="$HL_DIR/$theme_name" + theme_src_dir="$OUT_DIR/$theme_name" + theme_hl_dir="$HL_DIR/extracted_$theme_name" theme_out_dir="$OUT_DIR/$theme_name" - create_hyprcursors "$theme_src_dir" "$theme_hl_dir" "$theme_name" - compile_hyprcursors "$theme_hl_dir" "$theme_out_dir" + create_hyprcursors "$theme_src_dir" "$HL_DIR" "$theme_name" + compile_hyprcursors "$theme_hl_dir" "$theme_out_dir" "$theme_src_dir" done echo "[INFO] - Generating hyprcursor theme complete" fi diff --git a/default.nix b/default.nix index 722a2ab1..d9face24 100644 --- a/default.nix +++ b/default.nix @@ -3,6 +3,7 @@ , inkscape , just , xcursorgen +, xcur2png , hyprcursor , zip }: @@ -18,6 +19,7 @@ stdenvNoCC.mkDerivation { nativeBuildInputs = [ just xcursorgen + xcur2png inkscape hyprcursor zip diff --git a/shell.nix b/shell.nix index 1c1bbd0a..de9f1a79 100644 --- a/shell.nix +++ b/shell.nix @@ -1,13 +1,9 @@ -{ pkgs ? import { } }: - -pkgs.mkShell { - name = "dev-shell"; - buildInputs = with pkgs; [ - just - hyprcursor - inkscape - xorg.xcursorgen - zip - ]; -} - +{ + pkgs ? import { }, +}: +let + mainPkg = pkgs.callPackage ./default.nix { }; +in +mainPkg.overrideAttrs (oa: { + nativeBuildInputs = [ ] ++ (oa.nativeBuildInputs or [ ]); +}) \ No newline at end of file