Switch to hyprpaper

This commit is contained in:
Filippo Berto 2025-03-01 10:21:17 +01:00
parent 10534d485e
commit 8706085d15
Signed by: bertof
GPG key ID: 9DBF7E6A1D2CE9ED
2 changed files with 41 additions and 17 deletions

View file

@ -1,16 +1,29 @@
{ findutils
, gnugrep
, coreutils
, writeShellScriptBin
, swww
, hyprland
, backgrounds_directory ? "$HOME/Immagini/Sfondi/"
}: writeShellScriptBin "wl-update-background" ''
set -e
if [ $# -eq 0 ]; then
image=`${findutils}/bin/find ${backgrounds_directory} -type f | ${gnugrep}/bin/grep -v "/\." | ${coreutils}/bin/shuf -n 1`
else
image="$1"
fi
echo "image: $image"
${swww}/bin/swww img "$image"
''
}: writeShellScriptBin "wl-update-background"
# ''
# set -e
# if [ $# -eq 0 ]; then
# image=`${findutils}/bin/find ${backgrounds_directory} -type f | ${gnugrep}/bin/grep -v "/\." | ${coreutils}/bin/shuf -n 1`
# else
# image="$1"
# fi
# echo "image: $image"
# ${swww}/bin/swww img "$image"
# ''
''
set -euo pipefail
WALLPAPER_DIR=${backgrounds_directory}
CURRENT_WALL=$(hyprctl hyprpaper listloaded)
# Get a random wallpaper that is not the current one
WALLPAPER=$(${findutils}/bin/find "$WALLPAPER_DIR" -type f ! -name "$(${coreutils}/bin/basename "$CURRENT_WALL")" | ${coreutils}/bin/shuf -n 1)
# Apply the selected wallpaper
${hyprland}/bin/hyprctl hyprpaper reload ,"$WALLPAPER"
''