{ config, pkgs, lib, ... }:
{
  config = lib.mkIf config.system.desktop.enable {
    services.greetd = {
      enable = true;
      restart = true;
      settings = {
        terminal = {
          vt = 2;
          switch = true;
        };
        default_session.command = ''
          ${pkgs.greetd.tuigreet}/bin/tuigreet --remember --remember-user-session --user-menu --asterisks --sessions /etc/greetd/environments
        '';
      };
    };

    environment.etc = {
      "greetd/environments/sway.desktop".text = ''
        [Desktop Entry]
        Name=Sway
        Exec=sway --unsupported-gpu
      '';
      "greetd/environments/niri.desktop".text = ''
        [Desktop Entry]
        Name=Niri
        Exec=niri-session
      '';
      "greetd/environments/hyprland.desktop".text = ''
        [Desktop Entry]
        Name=Hyprland
        Exec=Hyprland
      '';
    };
  };
}
