nix-flakes/hosts/machine/kanade/modules/mac/wallpaper.nix
imnyang 70284509f3
Some checks failed
CI / check (push) Has been cancelled
CI / ida (push) Has been cancelled
CI / cpt (push) Has been cancelled
CI / build-nixos (ena) (push) Has been cancelled
CI / build-nixos (hako) (push) Has been cancelled
CI / build-nixos (kazusa) (push) Has been cancelled
CI / build-nixos (mizuki) (push) Has been cancelled
Initial commit
2026-07-03 16:53:49 +09:00

42 lines
959 B
Nix

{
pkgs,
inputs,
...
}:
let
wallpaper = "${inputs.self}/assets/wallpaper/wallpaper1.jpg";
setWallpaperScript = pkgs.writeShellScriptBin "set-wallpaper-script" ''
set -eu
# System Events runs in the logged-in Aqua session and updates every Space.
# Retry because launch agents can start before the desktop is fully ready.
for attempt in {1..12}; do
if /usr/bin/osascript <<'APPLESCRIPT'
tell application "System Events"
tell every desktop
set picture to "${wallpaper}"
end tell
end tell
APPLESCRIPT
then
exit 0
fi
/bin/sleep 5
done
exit 1
'';
in
{
environment.systemPackages = [ setWallpaperScript ];
launchd.user.agents.set-wallpaper = {
command = "${setWallpaperScript}/bin/set-wallpaper-script";
serviceConfig = {
RunAtLoad = true;
ProcessType = "Interactive";
LimitLoadToSessionType = "Aqua";
};
};
}