2024-05-11 20:55:27 +01:00
|
|
|
{
|
2024-05-12 11:09:46 +01:00
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
{
|
|
|
|
systemd.user.services.wallpaper-changer = {
|
|
|
|
Unit = {
|
|
|
|
Description = "Script to change wallpaper using swww";
|
2024-05-12 12:35:31 +01:00
|
|
|
PartOf = [ "hyprland-session.target" ];
|
|
|
|
After = [ "hyprland-session.target" ]; # or "wayland.target", depending on your system setup
|
2024-05-12 11:09:46 +01:00
|
|
|
};
|
|
|
|
Install = {
|
|
|
|
WantedBy = [ "default.target" ];
|
|
|
|
};
|
|
|
|
Service = {
|
2024-06-01 15:42:59 +01:00
|
|
|
Type = [ "simple" ];
|
2024-05-12 12:35:31 +01:00
|
|
|
ExecStart = "${pkgs.writeShellScript "swww-wallpaper-changer" ''
|
2024-05-12 11:09:46 +01:00
|
|
|
export WAYLAND_DISPLAY="wayland-1"
|
|
|
|
wallpaper_dir="$HOME/.local/share/bg/"
|
2024-06-01 15:42:59 +01:00
|
|
|
[ -d "$wallpaper_dir" ] || mkdir -p "$wallpaper_dir"
|
|
|
|
|
2024-05-12 12:35:31 +01:00
|
|
|
# Allow some time for desktop to start
|
|
|
|
sleep 3
|
|
|
|
echo "starting daemon..."
|
|
|
|
${pkgs.swww}/bin/swww-daemon &
|
2024-06-01 15:42:59 +01:00
|
|
|
|
2024-05-12 11:09:46 +01:00
|
|
|
while true; do
|
|
|
|
find "$wallpaper_dir" -type f -follow \( -iname \*.jpg -o -iname \*.png -o -iname \*.gif -o -iname \*.bmp \) | shuf | while read -r file; do
|
|
|
|
${pkgs.swww}/bin/swww img "$file" --transition-step 10 --transition-fps 60
|
2024-05-16 11:55:24 +01:00
|
|
|
[ $? != 0 ] && echo "swww failed, reloading daemon" && ${pkgs.swww}/bin/swww-daemon &
|
2024-05-12 12:35:31 +01:00
|
|
|
sleep 600
|
2024-05-12 11:09:46 +01:00
|
|
|
done
|
|
|
|
done
|
|
|
|
''}";
|
|
|
|
};
|
2024-05-11 20:55:27 +01:00
|
|
|
};
|
|
|
|
}
|