hyprwm / hyprlock

Hyprland's GPU-accelerated screen locking utility
BSD 3-Clause "New" or "Revised" License
712 stars 53 forks source link

Image `path` not updating with `reload_cmd` #431

Closed careb0t closed 4 weeks ago

careb0t commented 1 month ago

hyprlock.conf:

# # Player Art
image {
    monitor = HDMI-A-1
    path = 
    size = 300 # lesser side if not 1:1 ratio
    rounding = 5 # negative values mean circle
    border_size = 0
    rotate = 0 # degrees, counter-clockwise
    reload_time = 1
    reload_cmd = ~/scripts/albumart/albumart.sh
    position = 0, 0
    halign = center
    valign = center
    opacity=1
}

I'm trying to have my Spotify album art load on the lockscreen, but for some reason reload_cmd is not updating path with the filepath that the script outputs. For example, I can run the script myself and paste the output into path (ex: /home/careb0t/scripts/albumart/images/ab67616d0000b273590bbc64f2f84baca946b0f8.jpg), but whenever I leave the path blank for the script to update it, the image is never rendered.

If it matters, this is the script:

get_metadata() {
    key=$1
    playerctl metadata --format "{{ $key }}" 2>/dev/null
}

trackid=$(get_metadata "mpris:trackid")
    if [[ "$trackid" == *"spotify"* ]]; then
        url=$(get_metadata "mpris:artUrl")
        name=$(basename $url)
        if [ ! -f "images/$name.jpg" ]; then
            # File does not exist, download the image
            curl -o "images/$name.jpg" "$url"

        fi
        realpath "images/$name.jpg"

    else
        echo ""
    fi
PaideiaDilemma commented 1 month ago

Well you have 2 Problems.

  1. hyprlock's image widgets currently don't support jpg files. (Created #433 to fix that)
  2. Your script caused some issues for me. First use curl -o "images/$name.jpg" "$url" 2>/dev/null so that curl does not print stuff. Second, I would hardcode the path for images to /tmp/images or smth like that, since your current working directory will be different when ran by hyprlock.
PaideiaDilemma commented 1 month ago

I think this issue can be closed.