danth / stylix

System-wide colorscheming and typography for NixOS
https://stylix.danth.me/
MIT License
1.05k stars 126 forks source link

Use of hyprcursor for hyprland #478

Open Eddio0141 opened 1 month ago

Eddio0141 commented 1 month ago

https://wiki.hyprland.org/Hypr-Ecosystem/hyprcursor/

I don't see anything related to hyprcursor here, so I'm opening this Is there a reason it's not used? Or was this just not added yet

trueNAHO commented 1 month ago

I don't see anything related to hyprcursor here, so I'm opening this

Thanks for pointing this out!

Is there a reason it's not used? Or was this just not added yet

It was just not added yet.

danth commented 1 month ago

From the page you linked, I get the impression that Hyprcursor is simply an alternative file format for cursor themes. Are there any benefits to supporting this compared to using the traditional Xcursor format? According to the page, Hyprland supports both and will fall back to the traditional format if Hyprcursor is not configured.

Eddio0141 commented 1 month ago

You can read https://github.com/hyprwm/hyprcursor for more information, but as far as I know, its overall better than xcursor Hyprland itself has it built in already and only needs 2 env vars to enable it, so I don't see any downsides to adding this

danth commented 1 month ago

The main downside is that Xcursor will still be required for other compositors / apps which don't support Hyprcursor, so we have to support both formats as well as converting between them if possible

trueNAHO commented 1 month ago

IMHO, Vaxry's high-quality projects might eventually become the standard.

The main downside is that Xcursor will still be required for other compositors / apps which don't support Hyprcursor

Users not switching fully to Vaxry's ecosystem would face system bloat from duplicating functionalities.

Would it be a good idea to integrate Hyprcursor into the Stylix Hyprland module?

jaredmontoya commented 1 month ago

I support adding support for hyprcursors, but I am not sure if there are any hyprcursor themes in nixpkgs at the moment to test stylix support with.

I use bibata-cursors nixpkg, and it does not have a hyprcursor variant generated in it's output.

Someone could implement an overridable parameter for the bibata-cursors package that will allow to switch between cursor formats that are being generated.

Maybe somerthing like this will be approved by package maintainers:

cursor.package = pkgs.bibata-cursors; # cursorFormat is set to xcursor by default for backwards compatibility
cursor.package = pkgs.bibata-cursors.override { cursorFormat = "xcursor"; };
cursor.package = pkgs.bibata-cursors.override { cursorFormat = "hyprcursor"; };

To do that one will have to wait until clickgen supports hyprcursors and I think that it will because the issue for this is opened by the maintainer.

colexbruhn commented 1 month ago

I think we could get away with something a lot simpler. Hyprcursor provides hyprcursor-util which enables us to convert any xcursor packages to a hyprcursor compatible version.

So let's say the user specifies something like:

cursor.package = pkgs.bibata-cursors;

And then the cursors get installed somewhere like ~/.icons/bibata-cursors.

Then we could run:

# extract intermediate "working state"
hyprcursor-util -x ~/.icons/bibata-cursors -o ~/.icons/bibata-cursors-temp
# generate the hyprcursor compatible version
hyprcursor-util -c ~/.icons/bibata-cursors-temp -o ~/.icons/bibata-cursors-hypr
# remove leftover intermediate state
rm -rf ~/.icons/bibata-cursor-temp

Then we can just tell hyprland to use ~/.icons/bibata-cursors-hypr. This way, the user only needs to specify an xcursor theme, and the rest happens auto-magically.

jaredmontoya commented 1 month ago

I am not an expert in cursors so correct me if I am wrong.

As far as I know:

  1. xcursor format is a collection of raster images.
  2. hyprcursor allows to render the cursor from SVGs.
  3. if 1 is true and we convert xcursor to hyprcursor the resulting hyprcursor will not be infinitely crisp as a hyprcursor built from "source SVGs" defeating the purpose of using hyprcursor in the first place.
danth commented 1 month ago

Yes, converting Xcursor to Hyprcursor has no benefits as far as I can see, since Hyprland can load Xcursor directly anyway. Conversion in the other direction could be useful however.

See here (taken from #102) for an attempt at supporting different file formats under the same option, with automatic conversion between them - we may want to use something similar here.

trueNAHO commented 1 month ago

Related:

-- https://github.com/danth/stylix/pull/258#issuecomment-2019126625