2025-07-17 18:10:37 +02:00

67 lines
1.8 KiB
Nix

{
pkgs,
lib,
...
}:
let
wallpapers = [
../../../wallpapers/codioful-formerly-gradienta-lweK7Wme_jo-unsplash.jpg
../../../wallpapers/codioful-formerly-gradienta-n2XqPm7Bqhk-unsplash.jpg
../../../wallpapers/luke-chesser-eICUFSeirc0-unsplash.jpg
../../../wallpapers/luke-chesser-pJadQetzTkI-unsplash.jpg
../../../wallpapers/magicpattern-87PP9Zd7MNo-unsplash.jpg
];
monitor = ""; # leave empty to set the wallpaper on all monitors
wallpaperPicker = pkgs.writeShellScriptBin "wallpaper-picker" ''
#!/usr/bin/env bash
# use an array of wallpapers to randomly select one
wallpapers=(${pkgs.lib.concatStringsSep " " (map (p: "${p}") wallpapers)})
# select a random wallpaper from the array
index=$((RANDOM % ${toString (builtins.length wallpapers)}))
wallpaper="''${wallpapers[index]}"
echo "Setting wallpaper to: $wallpaper"
hyprctl hyprpaper unload all
hyprctl hyprpaper reload "${monitor},$wallpaper"
'';
in {
home.packages = [wallpaperPicker];
services.hyprpaper = {
enable = true;
settings = {
ipc = "on";
};
};
# systemd.user = {
# services.wallpaperRandomizer = {
# Install = {WantedBy = ["graphical-session.target"];};
# Unit = {
# Description = "Set random desktop background using hyprpaper";
# After = ["graphical-session-pre.target"];
# PartOf = ["graphical-session.target"];
# };
# Service = {
# Type = "oneshot";
# ExecStart = "${wallpaperRandomizer}/bin/wallpaperRandomizer";
# IOSchedulingClass = "idle";
# };
# };
# timers.wallpaperRandomizer = {
# Unit = {Description = "Set random desktop background using hyprpaper on an interval";};
# Timer = {OnUnitActiveSec = "6h";};
# Install = {WantedBy = ["timers.target"];};
# };
# };
}