end-4 / dots-hyprland

Modern, feature-rich and accessible desktop configuration.
https://end-4.github.io/dots-hyprland-wiki/en/
GNU General Public License v3.0
3.06k stars 196 forks source link

[Issue] Error when generating color for some wallpapers #606

Open ThePolishCat opened 2 weeks ago

ThePolishCat commented 2 weeks ago

The issue

When i generate for archwave.png and simple.png wallpaper from archlinux-wallpaper package, script crashes and ags break. Some wallpapers work, some wallpapers don't work.

Logs ```plain ./switchwall.sh Traceback (most recent call last): File "/home/cat/.config/ags/scripts/color_generation/generate_colors_material.py", line 70, in colors = QuantizeCelebi(list(image.getdata()), 128) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: QuantizeCelebi(): incompatible function arguments. The following argument types are supported: 1. (arg0: list[list[int]], arg1: int) -> dict[int, int] ```
lVentus commented 2 weeks ago

Mine didn't crash, but bar doesn't change its color. I found /home/ventus/.local/state/ags/scss/_material.scss is correct, but bar still load the scss from .config folder, instead of .local/state folder. Now I edited colorgen.sh and applycolor.sh to copy _material.scss to the .config folder. But this should be only a temporary solution, I should edit something in init.js? I tried but doesn't work, anyone can help?

By the way, when I dig the code, I found that, when I run these code in `applycolor.sh':

apply_ags() {
    ags run-js "handleStyles(false);"
    ags run-js 'openColorScheme.value = true; Utils.timeout(2000, () => openColorScheme.value = false);'
}

I only got these in tty

undefined
undefined

I try to run them directly in tty, I also got same result. Does it matter?

SchmidtSamuelo commented 1 week ago

Both of these images are P image modes. QuantizeCelebi seems to only support 2D formats, so RGB/CMYK etc... from that list.

One way to work around this is to just convert the image to an RGB before loading it. I was considering opening a PR to fix this since I ran into the same thing with a grayscale image (mode == 'L') but it looks like it might be slightly more involved. I don't know if end-4 would want to convert any 1D image array image mode to RGB prior to loading. I am able to reproduce this locally though if it helps.

In case you want to fix this yourself locally, the area to change would be https://github.com/end-4/dots-hyprland/blob/f4b223879a8ad56ae7c410d824bfcbc8258fa05f/.config/ags/scripts/color_generation/generate_colors_material.py#L65-L70

Simply add a check for image.mode. If the mode indicates the image data would be one dimensional, then just convert it to RGB using image = image.convert('RGB') or something.