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

let
  lockscreen_sway_config = pkgs.writeTextFile {
    name = "lockscreen.conf";
    text = ''
      set $lock ${pkgs.swaylock}/bin/swaylock -f -c 000000

      # Hotkey to lock the screen
      bindsym $mod+l exec $lock

      exec ${pkgs.swayidle}/bin/swayidle -w \
         timeout 300 '$lock' \
         timeout 600 '${pkgs.sway}/bin/swaymsg "output * dpms off"' \
              resume '${pkgs.sway}/bin/swaymsg "output * dpms on"' \
         before-sleep '$lock'
    '';
  };
in
{
  imports = [ ];

  config = lib.mkIf (config.me.graphical && config.me.sway.enable) {
    me.swayIncludes = [
      lockscreen_sway_config
    ];
  };
}