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

fix(hyprcursor): solve application consistency and scaling #29

Merged
merged 9 commits into from
Jun 9, 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
71 changes: 19 additions & 52 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -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=}
Expand All @@ -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"
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
, inkscape
, just
, xcursorgen
, xcur2png
, hyprcursor
, zip
}:
Expand All @@ -18,6 +19,7 @@ stdenvNoCC.mkDerivation {
nativeBuildInputs = [
just
xcursorgen
xcur2png
inkscape
hyprcursor
zip
Expand Down
22 changes: 9 additions & 13 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
{ pkgs ? import <nixpkgs> { } }:

pkgs.mkShell {
name = "dev-shell";
buildInputs = with pkgs; [
just
hyprcursor
inkscape
xorg.xcursorgen
zip
];
}

{
pkgs ? import <nixpkgs> { },
}:
let
mainPkg = pkgs.callPackage ./default.nix { };
in
mainPkg.overrideAttrs (oa: {
nativeBuildInputs = [ ] ++ (oa.nativeBuildInputs or [ ]);
})