|
| 1 | +#!/usr/bin/env bash |
| 2 | +# A wallpaper backend adapter for hyprpaper |
| 3 | +# * Notes |
| 4 | +# For future backends, this can be used as a base, just |
| 5 | +# change the hyprctl commands for the desired backend's commands |
| 6 | + |
| 7 | +# shellcheck source=$HOME/.local/bin/hyde-shell |
| 8 | +# shellcheck disable=SC1091 |
| 9 | +if ! source "$(which hyde-shell)"; then |
| 10 | + echo "[wallbash] code :: Error: hyde-shell not found." |
| 11 | + echo "[wallbash] code :: Is HyDE installed?" |
| 12 | + exit 1 |
| 13 | +fi |
| 14 | + |
| 15 | +# ? Be sure the wallpaper daemon is running |
| 16 | +if [[ ! -f "${XDG_RUNTIME_FIR}/hypr/$HYPRLAND_INSTANCE_SIGNATURE/hyprpaper.lock" ]]; then |
| 17 | + systemctl --user start hyprpaper.service || setsid hyprpaper & |
| 18 | + sleep 1 |
| 19 | +fi |
| 20 | + |
| 21 | +selected_wall="${1:-${XDG_CACHE_HOME:-$HOME/.cache}/hyde/wall.set}" |
| 22 | +[ -z "${selected_wall}" ] && echo "No input wallpaper" && exit 1 |
| 23 | +selected_wall="$(readlink -f "${selected_wall}")" |
| 24 | + |
| 25 | +#? hyprlock do not support videos, so we need to convert them to images |
| 26 | +is_video=$(file --mime-type -b "${selected_wall}" | grep -c '^video/') |
| 27 | +if [ "${is_video}" -eq 1 ]; then |
| 28 | + print_log -sec "wallpaper" -stat "converting video" "$selected_wall" |
| 29 | + mkdir -p "${HYDE_CACHE_HOME}/wallpapers/thumbnails" |
| 30 | + cached_thumb="$HYDE_CACHE_HOME/wallpapers/$(${hashMech:-sha1sum} "${selected_wall}" | cut -d' ' -f1).png" |
| 31 | + extract_thumbnail "${selected_wall}" "${cached_thumb}" |
| 32 | + selected_wall="${cached_thumb}" |
| 33 | +fi |
| 34 | + |
| 35 | +# ? Setting wallpaper using hyprctl IPC! |
| 36 | +# https://wiki.hypr.land/Hypr-Ecosystem/hyprpaper/#the-reload-keyword |
| 37 | +hyprctl hyprpaper reload ",${selected_wall}" |
0 commit comments