loqusion / hyprshade

Hyprland shader configuration tool
MIT License
222 stars 7 forks source link

search shade by name have flaws #18

Closed vincentaxhe closed 6 months ago

vincentaxhe commented 6 months ago

I create a new shade named 'blue-light-filter-gentle.glsl' in config/hypr/shaders, there already have a blue-light-filter.glsl in /usr/share/hyprshade/,but when blue-light-filter-gentle.glsl is applied when its blue-light-filter's turn, hyprshade auto can't switch to it. I have to rename blue-light-filter-gentle.glsl to gentle-blue-light-filter.glsl, in that way hyprshade can tell them apart. please check it ,I hope I am wrong.I just rename the file ,did not dig into the source file.

loqusion commented 6 months ago

You're not wrong, shader file resolution was literally being done with a glob like {name}* :P

Should be fixed in 7bddc33; lmk how it works for you!

vincentaxhe commented 6 months ago

I test it with some wired filenames. firstly hyprshade can tell blue-light-filter-gentle and gentle-blue-light-filter apart. But when I create blue-light-filter-gentle.glsl, and blue-light-filter-gentle..glsl, hyprshade failed to switch between them always targeting the one with dot, and ls with duplicate 'blue-light-filter-gentle.'. Seems like regex confusion about dot, though name like this is wired.

loqusion commented 6 months ago

a2fa48d3efd050827e14fb64e5e32a0b2116cff1 makes file name comparisons by stripping a single extension, should be sufficiently robust for any kind of file names.

vincentaxhe commented 6 months ago

Thanks for your persistent effort. This project is a good python learning material for me. Happy new year!

vincentaxhe commented 6 months ago

I made a git version PKGBUILD to get package updated, But I have not master how to git commit ,just paste it here.

# Maintainer: John Bernard <loqusion@gmail.com>
pkgname=hyprshade-git
_gitname=hyprshade
pkgver=2.0.1.r10.gb6de0db
pkgrel=1
pkgdesc="Hyprland shade configuration tool"
arch=('any')
url="https://github.com/loqusion/$_gitname"
license=('MIT')
_py_deps=(
    click
    more-itertools
)
depends=(
    hyprland
    "${_py_deps[@]/#/python-}"
    util-linux
)
makedepends=(git python-{build,hatchling,installer})
optdepends=('systemd: activate shader on schedule')
provides=($_gitname)
conflicts=($_gitname)
source=("git+$url.git"
        "https://raw.githubusercontent.com/loqusion/$_gitname/2.0.1/examples/config.toml")
sha256sums=('SKIP'
            '411517f06dc484fb8aad729d73d66cb5b91982ac0c5908184ec9343974392f0a')
pkgver()  {
  cd "$_gitname"
  git describe --long --tags | sed 's/-/.r/;s/-/./'
}
_get_wheel() {
    local wheel=
    local file
    for file in ./dist/${_gitname}-*.whl; do
        if [ -n "$wheel" ]; then
            echo "Multiple wheels found: $wheel and $file" >&2
            exit 1
        fi
        wheel=$file
    done
    echo "$wheel"
}

build() {
    cd "$_gitname"
    mkdir -p examples
    cp ../config.toml examples/

    /usr/bin/python -m build --wheel --no-isolation

    mkdir -p assets/completions
    local wheel=$(_get_wheel)
    export PYTHONPATH="$wheel"
    _HYPRSHADE_COMPLETE=bash_source /usr/bin/python "$wheel/$_gitname" >assets/completions/$_gitname.bash
    _HYPRSHADE_COMPLETE=fish_source /usr/bin/python "$wheel/$_gitname" >assets/completions/$_gitname.fish
    _HYPRSHADE_COMPLETE=zsh_source /usr/bin/python "$wheel/$_gitname" >assets/completions/_$_gitname
}

package() {
    cd "$_gitname"
    export PYTHONPYCACHEPREFIX="${PWD}/.cache/cpython/"
    /usr/bin/python -m installer --destdir="$pkgdir" dist/*.whl
    install -Dm0644 -t "$pkgdir/usr/share/licenses/$_gitname/" LICENSE
    install -Dm0644 -t "$pkgdir/usr/share/$_gitname/examples/" examples/*
    install -Dm0644 -t "$pkgdir/usr/share/bash-completion/completions/" assets/completions/$_gitname.bash
    install -Dm0644 -t "$pkgdir/usr/share/fish/vendor_completions.d/" assets/completions/$_gitname.fish
    install -Dm0644 -t "$pkgdir/usr/share/zsh/site-functions/" assets/completions/_$_gitname
}
loqusion commented 6 months ago

It's ok you didn't need to write your own hyprshade-git PKGBUILD, one already exists here.