{ config, lib, pkgs, ... }:


let
  inherit (config.services.betterlockscreen) package;
in
{
  services.betterlockscreen = {
    enable = true;
    arguments = [ "--display 1" "--" "-e" ];
    inactiveInterval = 15;
  };

  systemd.user.timers.updateBetterlockscreenImage = {
    Unit = {
      Description = "Update betterlockscreen image timer";
      After = [ "graphical-session.target" "timers.target" ];
    };

    Timer = {
      OnUnitActiveSec = "60min";
      OnBootSec = "10s";
    };

    Install = {
      WantedBy = [ "graphical-session.target" "timers.target" ];
    };
  };

  systemd.user.services.updateBetterlockscreenImage = {
    Unit = {
      Description = "Update betterlockscreen image";
      After = [ "graphical-session.target" ];
    };

    Service = {
      Type = "oneshot";
      Environment = "PATH=/run/current-system/sw/bin";
      ExecStart = "${package}/bin/betterlockscreen --display 1 --fx '' --update ${config.home.homeDirectory}/pictures/wallpapers";
    };

    Install = {
      WantedBy = [ "graphical-session.target" ];
    };
  };
}
