Fix hyprland background

This commit is contained in:
Filippo Berto 2026-01-16 14:13:58 +01:00
parent c6cae00eba
commit 02d9349a03
No known key found for this signature in database
GPG key ID: F1D17F9BCEC62FBC
3 changed files with 24 additions and 29 deletions

View file

@ -1,29 +1,19 @@
{ findutils
, coreutils
, writeShellScriptBin
{ coreutils
, findutils
, hyprland
, lib
, writeShellScriptBin
, backgrounds_directory ? "$HOME/Immagini/Sfondi/"
}: writeShellScriptBin "wl-update-background"
}: writeShellScriptBin "wl-update-background" ''
set -euo pipefail
PATH=$PATH:${lib.makeBinPath [findutils coreutils hyprland]}
WALLPAPER_DIR=${backgrounds_directory}
CURRENT_WALL=$(hyprctl hyprpaper listloaded)
CURRENT_WALL=$(basename "$CURRENT_WALL")
# ''
# 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"
# ''
# Get a random wallpaper that is not the current one
NEW_WALLPAPER=$(find "$WALLPAPER_DIR" -type f ! -name "$CURRENT_WALL" | shuf -n 1)
''
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"
''
# Apply the selected wallpaper
hyprctl hyprpaper reload ,"$NEW_WALLPAPER"
''