aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 74ec57b83914686ab59dcef5d77f7cbb8852c599 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# xcursor2svg

Please note that Generative AI was used for making this project

In GNOME >=51, it is now required to use only svg based cursor as xcursor got deprecated
now, I didn't want to give up on my xcursor themes, which were drawn by artists and not
something rasterized, what this script does is it takes the bitmap of each cursor frame,
resizes it with nearest-neighbor sampling, and embeds it in an svg as a base64 data URI.
This keeps the original pixel art intact while producing the svg cursors that newer
desktops expect. If you prefer the old approach, `--pixel` draws every visible pixel as
an SVG rectangle instead.

I tested this on [Hatsune Miku cursor theme by
supermariofps](https://github.com/supermariofps/hatsune-miku-windows-linux-cursors) and a
few other legacy xcursor themes. It worked pretty well for me on GNOME 51. Please open a
Pull request or submit an issue if something goes wrong. Thank you ^^

> [!IMPORTANT]
> This project requires `xcur2png`, `imagemagick`, and `base64` (part of coreutils), which
> you can find in your standard distro repos.

## Usage : 

```bash
./xcursor2svg.sh --res 64 ~/.icons/miku-cursor-linux # install from a old xcursor theme
./xcursor2svg.sh --res 64 -y /path/to/theme # Convert and install automatically
./xcursor2svg.sh --res 64 -n /path/to/theme # Convert only
./xcursor2svg.sh --res 64 --pixel /path/to/theme # Draw rectangles instead of embedding the bitmap
# For a theme already installed in a standard icon directory:
./xcursor2svg.sh --res 64 miku-cursor-linux
```

`--res` sets the nominal cursor size (default: 32). For each cursor, the closest
available Xcursor size is selected, preferring the larger size in a tie. All
frames at that size are resized with nearest-neighbor sampling and embedded in
the SVG as a base64 PNG. A source at the requested size keeps its pixels exactly;
resizing replicates or drops pixels, without smoothing.

Pass `--pixel` to use the older output format, where every visible pixel becomes
an SVG rectangle with its original color and transparency. That produces larger,
more verbose files but requires no embedded image data.

Animation order, delays, hotspots, and aliases are preserved in
`cursors_scalable/`, with missing GNOME/CSS names filled from legacy equivalents.
The original `cursors/` directory is copied for legacy applications. Canvas
dimensions and hotspots scale together; cropped or rectangular source cursors
are not stretched into squares.