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";
hash = "sha256-1QR3J+wgLVNjucPSVELv0FicNt+jM2KPLU5ubBfxjHI=";
};
swwwScript = ./swww.sh;
in {
home.file."wallpapers" = {
source = walls;
recursive = true;
};
home.file.".local/bin/set-wallpaper.sh" = {
source = ./set-wallpaper.sh;
home.packages = with pkgs; [
swww
];
home.file.".config/swww/swww.sh" = {
source = swwwScript;
executable = true;
};
home.packages = with pkgs; [
swww
bash
findutils
coreutils
];
systemd.user.services.swww = {
systemd.user.services."swww-daemon" = {
Unit = {
Description = "swww init (Wayland wallpaper daemon)";
Description = "SWWW daemon";
After = [ "graphical-session.target" ];
PartOf = [ "graphical-session.target" ];
};
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";
RestartSec = 2;
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
};
systemd.user.services."wallpaper-rotate" = {
systemd.user.services."change-wallpaper" = {
Unit = {
Description = "Rotate wallpaper via swww";
After = [ "swww.service" "graphical-session.target" ];
Wants = [ "swww.service" ];
Description = "Set/rotate wallpaper via swww";
After = [ "swww-daemon.service" "graphical-session.target" ];
};
Service = {
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 = {
WantedBy = [ "default.target" ];
WantedBy = [ "graphical-session.target" ];
};
};
systemd.user.timers."wallpaper-rotate" = {
systemd.user.timers."change-wallpaper" = {
Unit = {
Description = "Change wallpaper every 1 minute";
Description = "Timer to change wallpapers every hour";
};
Timer = {
OnBootSec = "30s";
OnUnitActiveSec = "1min";
Unit = "wallpaper-rotate.service";
OnCalendar = "hourly";
Persistent = true;
};
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