Skip to content

Commit

Permalink
refactor: change build system, revamp docs & speedup generation (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgoudham authored May 28, 2024
1 parent d3aa4fd commit a8aa241
Show file tree
Hide file tree
Showing 8,970 changed files with 270 additions and 190 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: build

on:
pull_request:

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: extractions/setup-just@v2
- name: Install dependencies
run: sudo apt update && sudo apt install -y inkscape x11-apps
- name: Generate cursors
run: just all
- name: Build zips
run: just zip
- name: Set outputs
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: 'catppuccin-cursors-${{ steps.vars.outputs.sha_short }}'
path: releases/*.zip
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions/checkout@v4
- uses: extractions/setup-just@v2
- name: Install dependencies
run: sudo apt update && sudo apt install -y inkscape
run: sudo apt update && sudo apt install -y inkscape x11-apps
- name: Generate cursors
run: just all
- name: Build zips
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
pngs/
releases/
5 changes: 3 additions & 2 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ Cursors:
Alexey varfolomeev <varlesh@gmail.com> - volantes-cursors

Colors:
elkrien <https://github.com/elkrien> - coloring cursors with Catppuccin palette
elkrien <https://github.com/elkrien> - coloring cursors with Catppuccin palette

Build script:
Sergei Eremenko <https://github.com/SmartFinn>
Keefer Rourke <keefer.rourke@gmail.com>
Moded by Efus10n & jnzhng from https://github.com/keeferrourke/capitaine-cursors
Moded by Efus10n & jnzhng from https://github.com/keeferrourke/capitaine-cursors
Goudham Suresh <https://github.com/sgoudham> - script performance improvements
38 changes: 0 additions & 38 deletions Makefile

This file was deleted.

117 changes: 68 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,73 +33,93 @@
<img src="https://raw.githubusercontent.com/catppuccin/cursors/main/assets/cursors-mocha.png"/>
</details>

## Info
## Acknowledgement

This project is a modification of [Volantes Cursors](https://github.com/varlesh/volantes-cursors) with the Catppuccin palettes.
This project is a modification of [Volantes Cursors](https://github.com/varlesh/volantes-cursors).

## Cursor sizes (pixels):
## Installation

<kbd>24</kbd>
<kbd>32</kbd>
<kbd>48</kbd>
<kbd>64</kbd>
### GitHub Release

## Usage
<!-- x-release-please-start-version -->

1. Clone this repository and go to downloaded directory:
```
git clone https://github.com/catppuccin/cursors.git
cd cursors
```
2. Extract selected theme from `cursors` directory:
- for local user to: `~/.icons`
- for all users to: `/usr/share/icons/`

&nbsp;
3. Choose theme in the Settings
1. Download your preferred flavor and accent from the [latest GitHub release](https://github.com/catppuccin/cursors/releases/tag/v0.2.0).

### For Arch Linux users
1. Extract the downloaded zip to one of the following locations:

- We have 4 individual packages which download GitHub release zips. Install them with you favourite AUR helper:
- **For the local user:** `$HOME/.icons`
- **For all users**: `/usr/share/icons`

```
yay -S catppuccin-cursors-mocha catppuccin-cursors-macchiato catppuccin-cursors-frappe catppuccin-cursors-latte
```
1. Choose the theme in your settings.

#### Example Installation

```bash
cd $HOME/.icons # or `/usr/share/icons`
curl -LOsS https://github.com/catppuccin/cursors/releases/download/v0.2.0/catppuccin-frappe-blue-cursors.zip
unzip catppuccin-frappe-blue-cursors.zip
```

- There also exists a `-git` package which builds the cursors from source. This package builds the cursors for all 4 variants and can take a lot of time to build depending on your system.
<!-- x-release-please-end -->

```
yay -S catppuccin-cursors-git
```
### Arch Linux

Individual flavor packages are available to download with your preferred AUR helper:

```bash
yay -S catppuccin-cursors-latte
yay -S catppuccin-cursors-frappe
yay -S catppuccin-cursors-macchiato
yay -S catppuccin-cursors-mocha
```

A `-git` package is also available which builds the cursors from source. This
package contains all variants of flavor and accent.

```bash
yay -S catppuccin-cursors-git
```

### NixOS

Nixpkgs has
[catppuccin-cursors](https://github.com/NixOS/nixpkgs/tree/nixos-23.11/pkgs/data/icons/catppuccin-cursors).
Use it by providing your preferred flavor + accent in camelCase. E.g.

### For Nix users
- nixpkgs has a single nix package which downloads the GitHub release zips.
- Use it by providing your preferred flavour + accent with the first letter in capital. Example:
```nix
pkgs.catppuccin-cursors.macchiatoPink
pkgs.catppuccin-cursors.mochaMauve
```
- It stores the cursor pack in `$out/share/icons/Catppuccin-<flavor>-<accent>-Cursors`, with the first letters of the flavor and accent in captial.

## Manual build from scratch
## Manual Installation

### Requirements

- [xcursorgen](https://wiki.archlinux.org/title/Xcursorgen) to generate the
cursors.
- [inkscape](https://wiki.inkscape.org/wiki/Inkscape) to convert SVGs to PNGs.
- **(Optional)** [just](https://github.com/casey/just) to easily run development
commands.

### Steps

1. Clone this repository and go to downloaded directory:
```
git clone https://github.com/catppuccin/cursors.git
cd cursors

```bash
git clone https://github.com/catppuccin/cursors.git
cd cursors
```
2. Make sure You have all dependencies installed:
- git
- make
- inkscape
- xcursorgen

3. Run the following commands (be aware that building takes a lot of time):
```
make build
sudo make install
```
4. Choose a theme in the Settings
1. Run the following command(s) if you have just installed, if not then look
inside the [justfile](./justfile) to understand what commands are being run.

```bash
just all # Build all flavor-accent variants.
just flavor mocha # To build all variants under one single flavor.
just accents mocha blue # To build only the blue variant under mocha.
just accents mocha 'blue mauve peach' # To build only the blue, mauve, and peach variants under mocha.
```

1. Extract built cursors in `./dist` to `$HOME/.icons` or `/usr/share/icons`.

## 💝 Thanks to

Expand All @@ -111,4 +131,3 @@ pkgs.catppuccin-cursors.macchiatoPink
<p align="center"><img src="https://raw.githubusercontent.com/catppuccin/catppuccin/main/assets/footers/gray0_ctp_on_line.svg?sanitize=true" /></p>
<p align="center">Copyright &copy; 2021-present <a href="https://github.com/catppuccin" target="_blank">Catppuccin Org</a>
<p align="center"><a href="https://github.com/catppuccin/cursors/blob/main/LICENSE"><img src="https://img.shields.io/static/v1.svg?style=for-the-badge&label=License&message=GNU&logoColor=d9e0ee&colorA=363a4f&colorB=b7bdf8"/></a></p>
127 changes: 127 additions & 0 deletions build
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#!/usr/bin/env bash

# Volantes cursors, based on KDE Breeze
# Copyright (c) 2016 Keefer Rourke <keefer.rourke@gmail.com>
# Copyright (c) 2020 Sergei Eremenko <https://github.com/SmartFinn>

set -eu

INKSCAPE_VERSION=$(inkscape --version 2>/dev/null | awk '/Inkscape[ ]/ {print $2; exit}')

# Generates the commands required for SVG -> PNG conversion
# These commands are to be used within inkscape's "shell" mode which allows for batch processing in a single inkscape process
generate_inkscape_commands() {
local src_dir="$1"
local out_dir="$2"
local file size bitmap_file

[ -d "$src_dir" ] || return 1
[ -d "$out_dir" ] || mkdir -p "$out_dir"

# shellcheck disable=SC2016
for file in "$src_dir"/*.svg; do
[ -f "$file" ] || continue
for size in 24 32 48 64; do
bitmap_file="${out_dir%/}/$(basename "$file" .svg)_${size}.png"
INKSCAPE_COMMANDS+="file-open:$file; export-filename:$bitmap_file; export-height:$size; export-width:$size; export-do; file-close;"
done
done
}

convert_to_x11cursor() {
local src_dir="$1"
local out_dir="$2"
local config base_name

[ -d "$src_dir" ] || return 1

if [ -d "$out_dir" ]; then
rm -rf "$out_dir"
fi

mkdir -p "$out_dir"

for config in "$CONFIG_DIR"/*.cursor; do
[ -f "$config" ] || continue
base_name="$(basename "$config" .cursor)"
xcursorgen -p "$src_dir" "$config" "$out_dir/$base_name"
done
}

create_aliases() {
local out_dir="$1"
local symlink target

while read -r symlink target; do
[ -e "$out_dir/$symlink" ] && continue
ln -sf "$target" "$out_dir/$symlink"
done <"$ALIASES"
}

SCRIPT_DIR="$(dirname "$0")"
SRC_DIR="$SCRIPT_DIR/src"
OUT_DIR="$SCRIPT_DIR/dist"
PNG_DIR="$SCRIPT_DIR/pngs"
BUILD_DIR="$SCRIPT_DIR/build"
CONFIG_DIR="$SRC_DIR/config"

AUTHORS="$SCRIPT_DIR/AUTHORS"
LICENSE="$SCRIPT_DIR/LICENSE"
ALIASES="$SRC_DIR/cursorList"

ACCENTS="blue dark flamingo green lavender light maroon mauve peach pink red rosewater sapphire sky teal yellow"
INKSCAPE_COMMANDS=""

while getopts "f:a:v" option; do
case $option in
f)
FLAVOR="$OPTARG"
;;
a)
ACCENTS="$OPTARG"
;;
v)
DEBUG=1
echo "[DEBUG] - Debug logging enabled"
;;
\?)
echo "Invalid option: -$OPTARG"
exit 1
;;
esac
done
echo "[INFO] - Flavor: '$FLAVOR'"
echo "[INFO] - Accent(s): '$ACCENTS'"

echo "[INFO] - Generating inkscape commands..."
for accent in $ACCENTS; do
theme_name="catppuccin-$FLAVOR-$accent-cursors"
theme_src_dir="$SRC_DIR/$theme_name"
theme_build_dir="$BUILD_DIR/$theme_name"
theme_out_dir="$OUT_DIR/$theme_name"
theme_png_dir="$PNG_DIR/$theme_name"

generate_inkscape_commands "$theme_src_dir" "$theme_png_dir"
done
echo "[INFO] - Generating inkscape commands complete"

echo "[INFO] - Converting SVGs to PNGs..."
inkscape --shell <<< ${INKSCAPE_COMMANDS} &> /dev/null
echo "[INFO] - Converting SVGs to PNGs complete"

echo "[INFO] - Converting to x11cursor & creating aliases..."
for accent in $ACCENTS; do
theme_name="catppuccin-$FLAVOR-$accent-cursors"
theme_src_dir="$SRC_DIR/$theme_name"
theme_build_dir="$BUILD_DIR/$theme_name"
theme_out_dir="$OUT_DIR/$theme_name"
theme_png_dir="$PNG_DIR/$theme_name"

convert_to_x11cursor "$theme_png_dir" "$theme_out_dir/cursors"
create_aliases "$theme_out_dir/cursors"

cp -f "$theme_src_dir/index.theme" "$theme_out_dir"
cp -f "$AUTHORS" "$theme_out_dir"
cp -f "$LICENSE" "$theme_out_dir"
done
echo "[INFO] - Converting to x11cursor & creating aliases complete"
Loading

0 comments on commit a8aa241

Please sign in to comment.