{ pkgs, nixosConfig, ... }:
with nixosConfig.nix-rice.lib;
let
  inherit (nixosConfig.nix-rice) rice;
in
{

  home.packages = builtins.attrValues {
    inherit (pkgs)
      rofimoji
      rofi-bluetooth
      rofi-power-menu
      rofi-vpn
      xdotool
      ;
  };

  programs.rofi = {
    enable = true;
    location = "center";
    font = "${rice.font.monospace.name} ${toString rice.font.monospace.size}";
    plugins = [ pkgs.rofi-calc ];
    extraConfig = {
      modi = "drun,run,ssh,window,calc";
    };
    terminal = "alacritty";
    theme = "onedark";
  };

  xdg.configFile."rofi/nord.rasi".text = ''
    * {
        nord0: #2e3440;
        nord1: #3b4252;
        nord2: #434c5e;
        nord3: #4c566a;
        nord4: #d8dee9;
        nord5: #e5e9f0;
        nord6: #eceff4;
        nord7: #8fbcbb;
        nord8: #88c0d0;
        nord9: #81a1c1;
        nord10: #5e81ac;
        nord11: #bf616a;
        nord12: #d08770;
        nord13: #ebcb8b;
        nord14: #a3be8c;
        nord15: #b48ead;

        background-color: @nord1;
        border: 0px;
        margin: 0px;
        padding: 0px;
        spacing: 0px;
        text-color: @nord4;
    }
    #inputbar {
        text-color: @nord3;
        padding: 6px;
        margin: 0px 0px 2px;
        children: [ entry ];
    }
    #entry {
        background-color: @nord3;
        text-color: @nord4;
        padding: 5px;
    }
    #message {
        border: 0px 0px 1px;
        border-color: @nord3;
        padding: 0px 0px 6px 7px;
    }
    #listview {
        lines: 10;
        padding: 2px 0px 0px;
        scrollbar: true;
    }
    #element {
        padding: 0px 0px 0px 7px;
        margin: 0px 0px 5px 0px;
        text-color: @nord4;
    }
    #element.normal.normal {
        text-color: @nord4;
    }
    #element.normal.urgent {
        text-color: @nord11;
    }
    #element.normal.active {
        text-color: @nord10;
    }
    #element.alternate.normal {
        text-color: @nord4;
    }
    #element.alternate.urgent {
        text-color: @nord11;
    }
    #element.alternate.active {
        text-color: @nord10;
    }
    #element.selected.normal {
        background-color: @nord8;
        text-color: @nord1;
    }
    #element.selected.urgent {
        background-color: @nord11;
        text-color: @nord4;
    }
    #element.selected.active {
        background-color: @nord10;
        text-color: @nord4;
    }
    #scrollbar {
        handle-color: @nord3;
        handle-width: 0.50em;
    }
    #button.selected {
        background-color: @nord8;
        text-color: @nord4;
    }
  '';
  xdg.configFile."rofi/onedark.rasi".text = ''
        /*
     * ROFI One Dark
     *
     * Based on OneDark.vim (https://github.com/joshdick/onedark.vim)
     *
     * Author: Benjamin Stauss
     * User: me-benni
     *
     */


    * {
      black:      #000000;
      red:        #eb6e67;
      green:      #95ee8f;
      yellow:     #f8c456;
      blue:       #6eaafb;
      mangenta:   #d886f3;
      cyan:       #6cdcf7;
      purple:     #C678DF;
      emphasis:   #50536b;
      text:       #dfdfdf;
      text-alt:   #b2b2b2;
      fg:         #abb2bf;
      bg:         #282c34;

      spacing: 0;
      background-color: transparent;

      font: "Knack Nerd Font 14";
      text-color: @text;
    }

    window {
      transparency: "real";
      fullscreen: true;
      background-color: #282c34dd;
    }

    mainbox {
      padding: 30% 30%;
    }

    inputbar {
      margin: 0px 0px 20px 0px;
      children: [prompt, textbox-prompt-colon, entry, case-indicator];
    }

    prompt {
      text-color: @blue;
    }

    textbox-prompt-colon {
      expand: false;
      str: ":";
      text-color: @text-alt;
    }

    entry {
      margin: 0px 10px;
    }

    listview {
      spacing: 5px;
      dynamic: true;
      scrollbar: false;
    }

    element {
      padding: 5px;
      text-color: @text-alt;
      highlight: bold #95ee8f; /* green */
      border-radius: 3px;
    }

    element selected {
      background-color: @emphasis;
      text-color: @text;
    }

    element urgent, element selected urgent {
      text-color: @red;
    }

    element active, element selected active {
      text-color: @purple;
    }

    message {
      padding: 5px;
      border-radius: 3px;
      background-color: @emphasis;
      border: 1px;
      border-color: @cyan;
    }

    button selected {
      padding: 5px;
      border-radius: 3px;
      background-color: @emphasis;
    }
  '';
}
