diff --git a/hyprcursor-util/README.md b/hyprcursor-util/README.md index 115d807..d2a02c3 100644 --- a/hyprcursor-util/README.md +++ b/hyprcursor-util/README.md @@ -15,4 +15,8 @@ Cursor themes can be in 3 states: `--extract | -x [path]` -> extract an xcursor theme into a working state -both commands support `--output | -o` to specify an output directory. This directory will be fully overwritten, and by default is `./theme` and `./extracted` respectively. \ No newline at end of file +both commands support `--output | -o` to specify an output directory. This directory will be fully overwritten, and by default is `./theme` and `./extracted` respectively. + +### Flags + +`--resize [mode]` - for `extract`: specify a default resize algorithm for shapes. Default is `none`. \ No newline at end of file diff --git a/hyprcursor-util/src/main.cpp b/hyprcursor-util/src/main.cpp index 56bf960..305294d 100644 --- a/hyprcursor-util/src/main.cpp +++ b/hyprcursor-util/src/main.cpp @@ -12,6 +12,8 @@ enum eOperation { OPERATION_EXTRACT = 1, }; +eResizeAlgo explicitResizeAlgo = RESIZE_INVALID; + struct XCursorConfigEntry { int size = 0, hotspotX = 0, hotspotY = 0, delay = 0; std::string image; @@ -349,7 +351,7 @@ static std::optional extractXTheme(const std::string& xpath, const } // write a meta.hl - std::string metaString = "resize_algorithm = none\n"; + std::string metaString = std::format("resize_algorithm = {}\n", explicitResizeAlgo == RESIZE_INVALID ? "none" : algoToString(explicitResizeAlgo)); // find hotspot from first entry metaString += @@ -431,6 +433,9 @@ int main(int argc, char** argv, char** envp) { if (arg == "-o" || arg == "--output") { out = argv[++i]; continue; + } else if (arg == "--resize") { + explicitResizeAlgo = stringToAlgo(argv[++i]); + continue; } else { std::cerr << "Unknown arg: " << arg << "\n"; return 1; diff --git a/libhyprcursor/internalSharedTypes.hpp b/libhyprcursor/internalSharedTypes.hpp index baf5364..c5ac601 100644 --- a/libhyprcursor/internalSharedTypes.hpp +++ b/libhyprcursor/internalSharedTypes.hpp @@ -4,9 +4,10 @@ #include enum eResizeAlgo { - RESIZE_NONE = 0, - RESIZE_BILINEAR = 1, - RESIZE_NEAREST = 2, + RESIZE_INVALID = 0, + RESIZE_NONE, + RESIZE_BILINEAR, + RESIZE_NEAREST, }; enum eShapeType { @@ -23,6 +24,17 @@ inline eResizeAlgo stringToAlgo(const std::string& s) { return RESIZE_BILINEAR; } +inline std::string algoToString(const eResizeAlgo a) { + switch (a) { + case RESIZE_BILINEAR: return "bilinear"; + case RESIZE_NEAREST: return "nearest"; + case RESIZE_NONE: return "none"; + default: return "none"; + } + + return "none"; +} + struct SCursorImage { std::string filename; int size = 0;