{ lib, config, pkgs, ... }:
let
  colorVariant = " black";
  gtkThemeFromScheme = import ./gtk-theme-gen.nix { inherit pkgs config; };
  wallpaperGen = import ./wallpaper-gen.nix { inherit pkgs config; };
in {

  config = lib.mkIf (config.homecfg.make.gui) {
    home.pointerCursor = {
      package = pkgs.bibata-cursors;
      name = "Bibata-Modern-Classic";
      size = 24;
      gtk.enable = true;
      x11.enable = true;
    };

    gtk = {
      enable = true;
      theme = {
        name = "${config.colorscheme.slug}";
        package = gtkThemeFromScheme;
      };
      iconTheme = {
        name = "tela-circle-icon-theme";
        package = pkgs.tela-circle-icon-theme;
      };
    };

    qt = {
      enable = true;
      platformTheme = "gtk";
    };

    home.packages = [ wallpaperGen pkgs.swww ];

    xdg.configFile."script/wallpaper.sh".text = ''
      #!/bin/sh

      NIXDIR=${wallpaperGen}
      WPDIR=$NIXDIR/share/wallpaper/

      IMGS=$(find $WPDIR -type f -print)


      RES=$(echo "$IMGS" | awk -v dir="$WPDIR" '{
          image_file = $0; 
          gsub("^" dir, "", image_file);
          print "img:" $0 ":text:" image_file;
      }')

      IMG=$WPDIR/$(echo "$RES" | wofi --dmenu --allow-images show-icons true -theme-str '#window { width: 50%; }' -p "Choose wallpaper:")
      IMG=$(echo "$IMG" | awk -F ':' '{print $2}')
      swww img $IMG
    '';
  };
}