{ lib, pkgs, ... }:

with lib;

let

  name = "lock";

  # desktop file
  # ------------
  # makes it possible to be used by other programs
  desktopFile = pkgs.writeTextFile {
    name = "${name}.desktop";
    destination = "/share/applications/${name}.desktop";
    text = ''
      [Desktop Entry]
      Categories=Application;Utility;
      Comment=Screen Saver
      Encoding=UTF-8
      Exec=${lockProgram}/bin/${name}
      Icon=gnome-lockscreen
      Name=${name}
      Terminal=false
      Type=Application
    '';
  };

  # the lock program
  lockProgram = pkgs.writeShellScriptBin "${name}" ''
    ${pkgs.xlockmore}/bin/xlock -mode life1d -size 1
  '';

in
{

  environment.systemPackages = [ lockProgram desktopFile ];
}