{ config, lib, ... }:
with lib;
let
  cfg = config.mjallen.programs.wlogout;
  nord = import (lib.snowfall.fs.get-file "modules/home/desktop/theme/nord.nix");
in
{
  imports = [ ./options.nix ];
  config = mkIf cfg.enable {
    programs.wlogout = {
      enable = false;
      layout = {
        lock = {
          label = "lock";
          action = "hyprlock --immediate";
          text = "Lock";
          keybind = "l";
        };
        hibernate = {
          label = "hibernate";
          action = "systemctl hibernate";
          text = "Hibernate";
          keybind = "h";
        };
        logout = {
          label = "logout";
          action = "sleep 1; hyprctl dispatch exit";
          text = "Logout";
          keybind = "e";
        };
        shutdown = {
          label = "shutdown";
          action = "systemctl poweroff";
          text = "Shutdown";
          keybind = "s";
        };
        suspend = {
          label = "suspend";
          action = "systemctl suspend";
          text = "Suspend";
          keybind = "u";
        };
        reboot = {
          label = "reboot";
          action = "reboot";
          text = "Reboot";
          keybind = "r";
        };
      };
      style = ''
        * {
          background-image: none;
        }

        window {
          background-color: ${nord.polarNight.nord0}f0
        }

        button {
          margin: 8px;
          color: ${nord.frost.nord7};
          background-color: ${nord.polarNight.nord1};
          border-style: solid;
          border-width: 2px;
          background-repeat: no-repeat;
          background-position: center;
          background-size: 25%;
        }

        button:active,
        button:focus,
        button:hover {
          color: ${nord.frost.nord8};
          background-color: ${nord.polarNight.nord2};
          outline-style: none;
        }

        #lock {
          background-image: image(url("icons/lock.png"));
        }

        #logout {
          background-image: image(url("icons/logout.png"));
        }

        #suspend {
          background-image: image(url("icons/suspend.png"));
        }

        #hibernate {
          background-image: image(url("icons/hibernate.png"));
        }

        #shutdown {
          background-image: image(url("icons/shutdown.png"));
        }

        #reboot {
          background-image: image(url("icons/reboot.png"));
        }
      '';
    };
  };
}
