summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorRyan Schanzenbacher <ryan@rschanz.org>2026-06-15 00:54:41 -0400
committerRyan Schanzenbacher <ryan@rschanz.org>2026-06-15 00:54:41 -0400
commit7adeedbdd6287517fca8c0b8080221e77ad79b54 (patch)
tree642d13739dc0c2d6cd88561101dbb10d3c69ef14 /modules
parent9e70f144dde840fed8d8b485f9396638139ec310 (diff)
Added wallpapers and logic to rotate them
Diffstat (limited to 'modules')
-rw-r--r--modules/darwin/random-wallpaper.nix40
1 files changed, 40 insertions, 0 deletions
diff --git a/modules/darwin/random-wallpaper.nix b/modules/darwin/random-wallpaper.nix
new file mode 100644
index 0000000..6b17c0f
--- /dev/null
+++ b/modules/darwin/random-wallpaper.nix
@@ -0,0 +1,40 @@
1{ config, lib, pkgs, ... }:
2let
3 cfg = config.local.randomWallpaper;
4 script = pkgs.writeShellApplication {
5 name = "set-random-wallpaper";
6 runtimeInputs = [ pkgs.coreutils pkgs.findutils ];
7 text = ''
8 set -euo pipefail
9 img=$(find "${cfg.directory}" \
10 -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' \) \
11 | shuf -n1)
12 [ -n "$img" ] || exit 0
13 /usr/bin/osascript -e "tell application \"System Events\" to tell every desktop to set picture to \"$img\""
14 '';
15 };
16in
17{
18 options.local.randomWallpaper = {
19 enable = lib.mkEnableOption "Random Rotating Wallpaper";
20 directory = lib.mkOption {
21 type = lib.types.str;
22 description = "Folder containing images";
23 };
24 interval = lib.mkOption {
25 type = lib.types.int;
26 default = 1800;
27 description = "Seconds between wallpaper changes";
28 };
29 };
30
31 config = lib.mkIf cfg.enable {
32 launchd.user.agents.random-wallpaper.serviceConfig = {
33 Label = "org.rschanz.wallpaperDaemon";
34 ProgramArguments = [ "${script}/bin/set-random-wallpaper" ];
35 StartInterval = cfg.interval;
36 RunAtLoad = true;
37 ProcessType = "Background";
38 };
39 };
40}