hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
19.55k stars 821 forks source link

hyprctl/hyprpaper: support keyword `reload` that combines `unload` and `preload` #2991

Open ppenguin opened 1 year ago

ppenguin commented 1 year ago

Description

If one keeps the current wallpaper under the same filename in a cache (e.g. the standard behaviour of styli.sh), it would be convenient to support reload after a file contents have changed, i.e.

hyprctl hyprpaper unload "~/.cache/styli.sh/wallpaper.jpg" && hyprctl hyprpaper preload "~/.cache/styli.sh/wallpaper.jpg"

becomes

hyprctl hyprpaper reload "~/.cache/styli.sh/wallpaper.jpg"
diegofariasm commented 9 months ago

Does your wallpaper actually change with this?

hyprctl hyprpaper unload "~/.cache/styli.sh/wallpaper.jpg" && hyprctl hyprpaper preload "~/.cache/styli.sh/wallpaper.jpg"

For me, even when i do something like this:

apply.sh


# Doing this works.
# # Kill hyprpaper
# # This is needed because
# # hyprpaper does not notice changes.
# pkill hyprpaper
# 
# # Run hyprpaper and disown it.
# nohup hyprpaper </dev/null >/dev/null 2>&1 & # completely detached from terminal

Doing this doesn't

hyprctl hyprpaper unload "~/.config/hypr/assets/wallpaper.png" hyprctl hyprpaper preload "~/.config/hypr/assets/wallpaper.png" hyprctl hyprpaper wallpaper ",~/.config/hypr/assets/wallpaper.png"

Nothing changes.

Output for hyprpaper:

 ./apply.sh 

ok ok ok


hyprpaper logs:

[LOG] Received a request: unload ~/.config/hypr/assets/wallpaper.png [LOG] Unloading target /home/enmei/.config/hypr/assets/wallpaper.png, preload path /run/user/1002/.hyprpaper_U0mC2c [LOG] Accepted incoming socket connection request on fd 5 [LOG] Closing Accepted Connection [LOG] Accepted incoming socket connection request on fd 5 [LOG] Received a request: preload ~/.config/hypr/assets/wallpaper.png [LOG] Preloaded target /home/enmei/.config/hypr/assets/wallpaper.png in 15.15ms -> Pixel size: [1600, 900] [LOG] Buffer created for target /home/enmei/.config/hypr/assets/wallpaper.png, Shared Memory usage: 5.8MB [LOG] Total SM usage for all buffers: 5.8MB [LOG] Accepted incoming socket connection request on fd 5 [LOG] Closing Accepted Connection [LOG] Accepted incoming socket connection request on fd 5 [LOG] Received a request: wallpaper ,~/.config/hypr/assets/wallpaper.png [LOG] Accepted incoming socket connection request on fd 5 [LOG] Closing Accepted Connection

ppenguin commented 9 months ago

It's a while ago, but I looked it up, and it seems it works for me.

I wrote a plugin for styli.sh that is executed when styli.sh runs to fetch a new wallpaper, and looks like this:

setwall_hyprpaper() {
    # shellcheck disable=SC2088
    ($SETWALL_EXE hyprpaper unload "$WALLPAPER" && hyprctl hyprpaper preload "$WALLPAPER" ) 2>&1 | outdbg
    # for now brute-force on all known monitors, because monitor wildcard doesn't work right
    $SETWALL_EXE monitors | awk '$1~/^Monitor/{print $2}' | while read -r m; do
        $SETWALL_EXE hyprpaper wallpaper "$m,$WALLPAPER" 2>&1 | outdbg
    done
}

Since the timed run indeed resets my WP, it appears to work...

jeanlucthumm commented 7 months ago

@ppenguin FYI you can use -j flag to output JSON and then jq to parse it:

$ hyprctl monitors -j | jq -r '.[0].name'
DP-1