19 lines
600 B
Nix
19 lines
600 B
Nix
{ coreutils
|
|
, findutils
|
|
, hyprland
|
|
, lib
|
|
, writeShellScriptBin
|
|
, backgrounds_directory ? "$HOME/Immagini/Sfondi/"
|
|
}: 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")
|
|
|
|
# Get a random wallpaper that is not the current one
|
|
NEW_WALLPAPER=$(find "$WALLPAPER_DIR" -type f ! -name "$CURRENT_WALL" | shuf -n 1)
|
|
|
|
# Apply the selected wallpaper
|
|
hyprctl hyprpaper reload ,"$NEW_WALLPAPER"
|
|
''
|