59 lines
1.4 KiB
Nix
59 lines
1.4 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}:
|
|
with lib; let
|
|
# load the wallpapers from the wallpapers directory
|
|
wallpapers = builtins.readDir ../../../wallpapers;
|
|
|
|
# script that picks a random wallpaper from the array and sets it as the desktop background
|
|
monitor = ""; # leave empty to set the wallpaper on all monitors
|
|
|
|
randomizer = pkgs.writeShellScriptBin "wallpaperRandomizer" ''
|
|
wallpaper=$(shuf -n 1 -e ${wallpapers[@]})
|
|
hyprctl hyprpaper unload all
|
|
hyprctl hyprpaper preload $wallpaper
|
|
hyprctl hyprpaper wallpaper "${monitor},${wallpaper}"
|
|
'';
|
|
|
|
in {
|
|
home.packages = [wallpaperRandomizer];
|
|
|
|
|
|
|
|
services.hyprpaper = {
|
|
enable = true;
|
|
|
|
settings = {
|
|
ipc = "off";
|
|
splash = false;
|
|
};
|
|
};
|
|
|
|
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"];};
|
|
};
|
|
};
|
|
} |