modules/darwin/random-wallpaper/default.nix

2070b29ae3b86654b7a8ad0a09a7ea4c63dfa73a · 846 B · 29 lines raw

1 { config, lib, pkgs, ... }:
2 let
3 cfg = config.local.randomWallpaper;
4 wallpaper-agent-src = ./wallpaper-daemon.swift;
5 in
6 {
7 options.local.randomWallpaper = {
8 enable = lib.mkEnableOption "Random Rotating Wallpaper";
9 directory = lib.mkOption {
10 type = lib.types.str;
11 description = "Folder containing images";
12 };
13 interval = lib.mkOption {
14 type = lib.types.int;
15 default = 1800;
16 description = "Seconds between wallpaper changes";
17 };
18 };
19
20 config = lib.mkIf cfg.enable {
21 launchd.user.agents.random-wallpaper.serviceConfig = {
22 Label = "org.rschanz.wallpaperDaemon";
23 ProgramArguments = [ "/usr/bin/swift" "${wallpaper-agent-src}" "${cfg.directory}" "${builtins.toString cfg.interval}" ];
24 RunAtLoad = true;
25 KeepAlive = true;
26 ProcessType = "Background";
27 };
28 };
29 }