fix error

This commit is contained in:
2025-10-29 21:13:44 +09:00
parent a59676dd23
commit f0c302ac49
3 changed files with 39 additions and 41 deletions
+28 -23
View File
@@ -6,61 +6,66 @@ let
rev = "40912e6418737e93b59a38bcf189270cbf26656d"; rev = "40912e6418737e93b59a38bcf189270cbf26656d";
hash = "sha256-1QR3J+wgLVNjucPSVELv0FicNt+jM2KPLU5ubBfxjHI="; hash = "sha256-1QR3J+wgLVNjucPSVELv0FicNt+jM2KPLU5ubBfxjHI=";
}; };
swwwScript = ./swww.sh;
in { in {
home.file."wallpapers" = { home.file."wallpapers" = {
source = walls; source = walls;
recursive = true; recursive = true;
}; };
home.file.".local/bin/set-wallpaper.sh" = { home.packages = with pkgs; [
source = ./set-wallpaper.sh; swww
];
home.file.".config/swww/swww.sh" = {
source = swwwScript;
executable = true; executable = true;
}; };
home.packages = with pkgs; [ systemd.user.services."swww-daemon" = {
swww
bash
findutils
coreutils
];
systemd.user.services.swww = {
Unit = { Unit = {
Description = "swww init (Wayland wallpaper daemon)"; Description = "SWWW daemon";
After = [ "graphical-session.target" ]; After = [ "graphical-session.target" ];
PartOf = [ "graphical-session.target" ];
}; };
Service = { Service = {
ExecStart = [ "${pkgs.swww}/bin/swww" "init" ]; Type = "simple";
Environment = [
"PATH=${lib.makeBinPath [ pkgs.swww pkgs.coreutils pkgs.findutils pkgs.bash ]}:$PATH"
];
ExecStart = "${pkgs.bash}/bin/bash -lc 'if swww query >/dev/null 2>&1; then exit 0; else exec swww-daemon -f xrgb; fi'";
Restart = "on-failure"; Restart = "on-failure";
RestartSec = 2;
}; };
Install = { Install = {
WantedBy = [ "graphical-session.target" ]; WantedBy = [ "graphical-session.target" ];
}; };
}; };
systemd.user.services."wallpaper-rotate" = { systemd.user.services."change-wallpaper" = {
Unit = { Unit = {
Description = "Rotate wallpaper via swww"; Description = "Set/rotate wallpaper via swww";
After = [ "swww.service" "graphical-session.target" ]; After = [ "swww-daemon.service" "graphical-session.target" ];
Wants = [ "swww.service" ];
}; };
Service = { Service = {
Type = "oneshot"; Type = "oneshot";
ExecStart = [ "${pkgs.bash}/bin/bash" "/home/moons/.local/bin/set-wallpaper.sh" ]; Environment = [
"PATH=${lib.makeBinPath [ pkgs.swww pkgs.coreutils pkgs.findutils pkgs.bash ]}:$PATH"
];
ExecStart = "${pkgs.bash}/bin/bash -lc '$HOME/.config/swww/swww.sh'";
}; };
Install = { Install = {
WantedBy = [ "default.target" ]; WantedBy = [ "graphical-session.target" ];
}; };
}; };
systemd.user.timers."wallpaper-rotate" = { systemd.user.timers."change-wallpaper" = {
Unit = { Unit = {
Description = "Change wallpaper every 1 minute"; Description = "Timer to change wallpapers every hour";
}; };
Timer = { Timer = {
OnBootSec = "30s"; OnCalendar = "hourly";
OnUnitActiveSec = "1min";
Unit = "wallpaper-rotate.service";
Persistent = true; Persistent = true;
}; };
Install = { Install = {
-18
View File
@@ -1,18 +0,0 @@
#!/usr/bin/env bash
# set-wallpaper.sh
set -euo pipefail
WALLS="${HOME}/wallpapers"
if ! swww query >/dev/null 2>&1; then
swww init
fi
mapfile -t files < <(find "$WALLS" -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.webp' \))
[[ ${#files[@]} -gt 0 ]] || exit 0
pick="${files[RANDOM % ${#files[@]}]}"
exec swww img "$pick" --transition-type any --transition-step 90 --transition-fps 60
+11
View File
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
WALLPAPERS_DIR="${HOME}/wallpapers"
mapfile -t files < <(find "$WALLPAPERS_DIR" -type f 2>/dev/null)
[ "${#files[@]}" -eq 0 ] && exit 0
file="$(printf '%s\n' "${files[@]}" | shuf -n 1)"
exec swww img "$file" --transition-type grow --transition-step 90