{ windows-theme
, system
, lib
, config
, ...
}:
{
  options = {
    nixp.mate = {
      enable = lib.mkEnableOption "enable this configuration";
      panel.enable = lib.mkEnableOption "enable panel settings for mate";

      background = {
        enable = lib.mkEnableOption "enable and set background for mate";
        path = lib.mkOption {
          type = lib.types.path;
          default = ../assets/wall.png;
          description = "Set path to the background";
        };
      };

      theme = {
        enable = lib.mkEnableOption "enable windows xp gtk theme for mate";
        name = lib.mkOption {
          type = lib.types.enum [ "Windows XP Luna" "Windows XP Embedded" "Windows XP Homestead" "Windows XP Metallic" "Windows XP Royale" "Windows XP Royale Dark" "Windows XP Zune" ];
          default = "Windows XP Luna";
          description = "set the windows xp gtk theme for mate";
        };
      };

      cursor = {
        enable = lib.mkEnableOption "enable windows xp cursor theme for mate";
      };

      icon = {
        enable = lib.mkEnableOption "enable windows xp icon theme for mate";
      };
    };
  };

  config = lib.mkMerge [
    (lib.mkIf config.nixp.mate.enable {
      nixp.mate = {
        panel.enable = lib.mkDefault true;
        theme.enable = lib.mkDefault true;
        background.enable = lib.mkDefault true;
        cursor.enable = lib.mkDefault true;
        icon.enable = lib.mkDefault true;
      };

      gtk = {
        enable = true;
      };
    })
    (lib.mkIf config.nixp.mate.panel.enable {
      dconf.settings = {
        "org/mate/panel/general" = {
          toplevel-id-list = [ "bottom" ];
          object-id-list = [
            "menu-bar"
            "window-list"
            "notification-area"
            "brightness"
            "clock"
            "poweroff"
          ];
        };

        "org/mate/panel/toplevels/bottom" = {
          orientation = "bottom";
          y-bottom = 0;
        };

        "org/mate/panel/menubar" = {
          item-icon-size = "32px";
          show-places = false;
          show-desktop = false;
          icon-name = "";
        };

        "org/mate/panel/objects/menu-bar" = {
          locked = true;
          object-type = "menu-bar";
          panel-right-stick = false;
          position = 0;
          toplevel-id = "bottom";
        };

        "org/mate/panel/objects/window-list" = {
          locked = true;
          applet-iid = "WnckletFactory::WindowListApplet";
          object-type = "applet";
          #panel-right-stick = ;
          position = 20;
          toplevel-id = "bottom";
        };

        # "org/mate/panel/objects/battery" = {
        #   locked = true;
        #   applet-iid = "BattstatAppletFactory::BattstatApplet";
        #   object-type = "applet";
        #   panel-right-stick = true;
        #   position = 222;
        #   toplevel-id = "bottom";
        # };

        # "org/mate/panel/objects/battery/prefs" = {
        #   red-value = 15;
        #   red-value-is-tiem = false;
        #   show-text = 1;
        # };

        "org/mate/panel/objects/notification-area" = {
          locked = true;
          applet-iid = "NotificationAreaAppletFactory::NotificationArea";
          object-type = "applet";
          panel-right-stick = true;
          position = 182;
          toplevel-id = "bottom";
        };

        "org/mate/panel/objects/brightness" = {
          locked = true;
          applet-iid = "BrightnessAppletFactory::BrightnessApplet";
          object-type = "applet";
          panel-right-stick = true;
          position = 158;
          toplevel-id = "bottom";
        };

        "org/mate/panel/objects/clock" = {
          locked = true;
          applet-iid = "ClockAppletFactory::ClockApplet";
          object-type = "applet";
          panel-right-stick = true;
          position = 124;
          toplevel-id = "bottom";
        };

        "org/mate/panel/objects/clock/prefs" = {
          expand-locations = false;
          show-temperature = false;
          show-weather = false;
          show-date = false;
        };

        "org/mate/panel/objects/poweroff" = {
          locked = true;
          object-type = "action";
          action-type = "shutdown";
          panel-right-stick = true;
          position = 24;
          toplevel-id = "bottom";
        };
      };
    })
    (lib.mkIf config.nixp.mate.background.enable {
      home.file.".background-image".source = config.nixp.mate.background.path;
      dconf.settings = {
        "org/mate/desktop/background" = {
          picture-filename = ".background-image";
        };
      };
    })
    (lib.mkIf config.nixp.mate.theme.enable {
      dconf.settings = {
        "org/mate/desktop/interface" = {
          gtk-theme = config.nixp.mate.theme.name;
          icon-theme = "windows-xp-icon-theme";
        };

        "org/mate/marco/general" = {
          theme = config.nixp.mate.theme.name;
        };
      };

      gtk = {
        theme = {
          name = config.nixp.mate.theme.name;
          package = windows-theme.packages.${system}.windows-xp-theme;
        };
      };
    })
    (lib.mkIf config.nixp.mate.cursor.enable {
      dconf.settings = {
        "org/mate/desktop/peripherals/mouse" = {
          cursor-theme = "ModernXP";
        };
      };
      gtk = {
        cursorTheme = {
          name = "ModernXP";
          package = windows-theme.packages.${system}.windows-xp-cursor;
        };
      };
    })
    (lib.mkIf config.nixp.mate.icon.enable {
      dconf.settings = {
        "org/mate/desktop/interface" = {
          icon-theme = "windows-xp-icon-theme";
        };
      };

      gtk = {
        iconTheme = {
          name = "windows-XP";
          package = windows-theme.packages.${system}.windows-xp-icons;
        };
      };
    })
  ];
}
