{ config, pkgs, rice, ... }:
let
  # theme-name = "Colloid-Pink-Dark-Compact";
  # theme-package = pkgs.colloid-gtk-theme.override {
  #   themeVariants = [ "pink" ];
  #   colorVariants = [ "dark" ];
  #   sizeVariants = [ "compact" ]; 
  #   tweaks = [ "black" ]; 
  # };

  # theme-name = "catppuccin-macchiato-pink-compact+rimless,black";
  # theme-package = pkgs.catppuccin-gtk.override {
  #   accents = [ "pink" ];
  #   size = "compact";
  #   tweaks = [ "rimless" "black" ];
  #   variant = "macchiato";
  # };
  theme-name = "Materia-dark-compact";
  theme-package = pkgs.materia-theme-transparent;
  # theme-name = "numix";
  # theme-name = "adw-gtk3-dark";
  # theme-package = pkgs.adw-gtk3;
  # theme-package = let
  #   theme-string = with rice.color; let 
  #     h = rice.lib.nohash;
  #     d = rice.lib.float-to-drune;
  #   in /* ini */ ''
  #     BG=${h background}
  #     FG=${h foreground}
  #     SEL_BG=${h accent.base}
  #     SEL_FG=${h black.base}
  #     ACCENT_BG=${h accent.base}
  #     TXT_BG=${h black.dark}
  #     TXT_FG=${h foreground}
  #     HDR_BG=${h background}
  #     HDR_FG=${h foreground}
  #     BTN_BG=${h accent.dark}
  #     BTN_FG=${h foreground}
  #     HDR_BTN_BG=${h accent.dark}
  #     HDR_BTN_FG=${h foreground}
  #     WM_BORDER_FOCUS=${h border}
  #     WM_BORDER_UNFOCUS=${h accent.dark}
  #     ROUNDNESS=${builtins.toString rice.rounding}
  #     ROUNDNESS_GTK2_HIDPI=${builtins.toString rice.rounding}
  #     OUTLINE_WIDTH=${builtins.toString rice.border-width}
  #     BTN_OUTLINE_OFFSET=-3
  #     BTN_OUTLINE_WIDTH=1
  #     SPACING=${builtins.toString rice.gap-size}
  #     GRADIENT=0.0
  #     CINNAMON_OPACITY=${builtins.toString rice.transparency}
  #     INACTIVE_FG=${h foreground}
  #     INACTIVE_TXT_FG=${h foreground}
  #     INACTIVE_HDR_FG=${h foreground}
  #     ICONS_DARK=${h accent.dark}
  #     ICONS_MEDIUM=${h accent.base}
  #     ICONS_LIGHT=${h accent.bright}
  #     ICONS_LIGHT_FOLDER=${h accent.base}
  #     ICONS_SYMBOLIC_ACTION=${h accent.base}
  #     ICONS_SYMBOLIC_PANEL=${h accent.base}
  #     ICONS_STYLE=icons_papirus
  #     CARET1_FG=${h white.dark}
  #     CARET2_FG=${h black.bright}
  #     CARET_SIZE=0.04
  #     MENU_BG=${h accent.dark}
  #     MENU_FG=${h foreground}
  #     OUTLINE_WIDTH=${builtins.toString rice.border-width}
  #     SPOTIFY_PROTO_BG=${h accent.dark}
  #     SPOTIFY_PROTO_FG=${h foreground}
  #     SPOTIFY_PROTO_SEL=${h blue.base}
  #     BASE16_GENERATE_DARK=False
  #     BASE16_INVERT_TERMINAL=False
  #     BASE16_MILD_TERMINAL=False
  #     UNITY_DEFAULT_LAUNCHER_STYLE=False
  #   '';
  #   # theme-source-pkg = pkgs.materia-theme;
  #   theme-source-pkg = pkgs.themix-gui;
  # in pkgs.stdenv.mkDerivation {
  #   name = "oomox-gtk";
  #   version = theme-source-pkg.version;
  #   src = theme-source-pkg.src;
  #   dontBuild = true;
  #   nativeBuildInputs = with pkgs; [
  #     glib
  #     libxml2
  #     bc
  #   ];
  #   buildInputs = with pkgs; [
  #     gnome-themes-extra
  #     gdk-pixbuf
  #     librsvg
  #     sassc
  #     inkscape
  #     optipng
  #   ];
  #   propagatedUserEnvPkgs = with pkgs; [
  #     gtk-engine-murrine
  #   ];
  #   # installPhase = ''
  #   #   mkdir -p $out/share/themes/materia
  #   #   patchShebangs .
  #   #   ./change_color.sh -o materia -t $out/share/themes <(echo -e "${theme-string}")
  #   # '';
  #   installPhase = ''
  #     mkdir -p $out/share/icons/icons_papirus
  #     mkdir -p $out/share/icons/icons_numix
  #     mkdir -p $out/share/icons/icons_suruplus
  #     echo "${theme-string}" > $out/oomox.colors
  #     pushd plugins/icons_papirus
  #     patchShebangs .
  #     ./change_color.sh -o icons_papirus -d $out/share/icons/icons_papirus $out/oomox.colors
  #     popd
  #     pushd plugins/icons_numix
  #     patchShebangs .
  #     ./change_color.sh -o icons_numix -d $out/share/icons/icons_numix $out/oomox.colors
  #     popd
  #     pushd plugins/icons_suruplus
  #     patchShebangs .
  #     ./change_color.sh -o icons_suruplus -d $out/share/icons/icons_suruplus $out/oomox.colors
  #     popd
  #     mkdir -p $out/share/themes/numix
  #     pushd plugins/theme_oomox
  #     patchShebangs .
  #     HOME=$out ./change_color.sh -o numix -m all -t $out/share/themes $out/oomox.colors
  #     popd
  #   '';
  #   meta = {
  #     description = "custom theme utility";
  #     homepage = "https://github.com/themix-project/themix-gui";
  #     maintainers = [ ];
  #   };
  # };
in {
  home = {
    packages = with pkgs; [
      # gnome.gnome-themes-extra
      adwaita-icon-theme
      gnome-tweaks
      gtk3
      gtk4
      # catppuccin-gtk
      bibata-cursors
    ] ++ [
      # pkgs-unstable.themix-gui
    ];
    sessionVariables.GTK_THEME = theme-name;
    pointerCursor = {
      gtk.enable = true;
      x11.enable = true;
    } // rice.cursor;
  };
  gtk = {
    enable = true;
    theme = {
      name = theme-name;
      package = theme-package;
    };
    gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc";
    gtk3 = {
      extraConfig.gtk-application-prefer-dark-theme = 1;
      # extraCss = with rice.color; /* css */ ''
      #   wnck-pager {
      #     color: ${black.bright};
      #     background-color: ${background};
      #   }

      #   wnck-pager:selected {
      #     color: ${background};
      #     background-color: ${accent.base};
      #   }
      # '';
        # window.background {
        #   background-color: rgba(${rice.lib.hex-to-rgb-comma-string background},${builtins.toString rice.transparency});
        # }
        # .background, .view, .surface, .frame, box, window.decoration, stack {
        #   background-color: transparent;
        # }
    };
    gtk4 = {
      extraConfig.gtk-application-prefer-dark-theme = 1;
      extraCss = config.gtk.gtk3.extraCss;
    };
    cursorTheme = rice.cursor;
  };
  xdg.configFile = {
    "gtk-4.0/assets".source = "${theme-package}/share/themes/${theme-name}/gtk-3.20/assets";
    "gtk-4.0/gtk.css".source = "${theme-package}/share/themes/${theme-name}/gtk-3.20/gtk.css";
    "gtk-4.0/gtk-dark.css".source = "${theme-package}/share/themes/${theme-name}/gtk-3.20/gtk-dark.css";
  };
  dconf = {
    enable = true;
    settings = {
      "org/gnome/desktop/interface" = {
        color-scheme = "prefer-dark";
        # gtk-theme = theme-name;
      };
    };
  };
}
