Skip to content

cursors: add `kcursorgen` command to generate SVG and Xcursor themes

Jin Liu requested to merge work/genericity/kcursorgen into master

USAGE:

This adds a new command-line tool, kcursorgen, which has 2 modes:

  1. kcursorgen --build-svg-theme --theme-dir <dir> --src-dir <dir> --alias-file <path> --delay <ms> --xcursor-config-dir <dir>

Generates an SVG theme from the SVG source files in the given directory. It copies SVG source files into <theme-dir>/cursors_scalable and generates metadata.json files.

The SVG source files should contain a hidden hotspot element, whose coordinates are extracted into metadata.json. Alternatively, you can specify --xcursor-config-dir so hotspot and delay is read from *.cursor config files there.

NOTE: This mode doesn't copy the index.theme file. You need to copy it manually.

  1. kcursorgen --svg-theme-to-xcursor --theme-dir <dir> [--sizes <size1>,<size2>,...]

Converts an SVG theme in <theme-dir>/cursors_scalable into an Xcursor theme in <theme-dir>/cursors.

You can specify sizes to render with --sizes option, as a comma-separated list of integers.

RATIONALE:

The original build script for the Breeze cursor theme requires PyQt/PySide and Inkscape. This rewrites it in C++, so now it only depends on QtSvg and xcursorgen. It can be integrated into the normal cmake build, instead of having to manually run the build script every time the theme is modified.

Also, distro packagers can now build the cursor theme in more sizes if they like, or even choose to only package the SVG theme, and build the XCursor theme in a postinstall script on the user's machine.

It might also be useful if we are to allow the user to set arbitrary cursor size in the future. An XCursor theme of the chosen size can be generated on the fly.

Edited by Jin Liu

Merge request reports