summaryrefslogtreecommitdiff
path: root/modules/darwin/random-wallpaper/module.nix
blob: b20ce8818faf519a2d74773edbd1f0ae8e18af7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{ config, lib, pkgs, ... }:
let
  cfg = config.local.randomWallpaper;
  wallpaper-agent-src = ./wallpaper-daemon.swift;
in
{
  options.local.randomWallpaper = {
    enable = lib.mkEnableOption "Random Rotating Wallpaper";
    directory = lib.mkOption {
      type = lib.types.str;
      description = "Folder containing images";
    };
    interval = lib.mkOption {
      type = lib.types.int;
      default = 1800;
      description = "Seconds between wallpaper changes";
    };
  };

  config = lib.mkIf cfg.enable {
    launchd.user.agents.random-wallpaper.serviceConfig = {
      Label = "org.rschanz.wallpaperDaemon";
      ProgramArguments = [ "/usr/bin/swift" "${wallpaper-agent-src}" "${cfg.directory}" "${builtins.toString cfg.interval}" ];
      RunAtLoad = true;
      KeepAlive = true;
      ProcessType = "Background";
    };
  };
}