{ config, pkgs, lib, ... }:

{
  home.packages = with pkgs; [
    arandr
    feh
    dmenu
    i3lock-blur
    xclip
  ];

  xsession.windowManager.i3.enable = true;

  xsession.windowManager.i3.config = {
    fonts = {
      names = [ "Ubuntu" ];
      style = "Regular";
      size = 12.0;
    };
    defaultWorkspace = "1";
    bars = [{
      position = "top";
      colors.background = "#ef5ffc";
      colors.focusedWorkspace = {
        text = "#333333";
        border = "#ef5ffc";
        background = "#a15ffc";
      };
      colors.inactiveWorkspace = {
        text = "#333333";
        border = "#ef5ffc";
        background = "#ef5ffc";
      };
      colors.statusline = "#333333";
      fonts = {
        names = [ "Ubuntu" ];
        style = "Regular";
        size = 13.0;
      };
      statusCommand = "~/.borg/i3status-bakage.sh";
      extraConfig = ''
        height 24
      '';
    }];
    colors.focused = {
      border = "#ef5ffc";
      background = "#ef5ffc";
      text = "#333333";
      indicator = "#2e9ef4";
      childBorder = "#ef5ffc";
    };
    floating = {
      criteria = [
        {
          instance = "keepassxc";
          class = "KeePassXC";
        }
      ];
    };
    gaps = {
      inner = 8;
      smartBorders = "on";
      smartGaps = true;
    };
    keybindings = 
      let
        modifier = config.xsession.windowManager.i3.config.modifier;
        menu = config.xsession.windowManager.i3.config.menu;
      in lib.mkOptionDefault {
        "${modifier}+space" = "exec ${menu}";
        "${modifier}+Control+Space" = "focus mode_toggle";
        "XF86AudioLowerVolume" = "exec pactl set-sink-volume @DEFAULT_SINK@ -5%";
        "XF86AudioRaiseVolume" = "exec pactl set-sink-volume @DEFAULT_SINK@ +5%";
        "XF86AudioMute" = "exec pactl set-sink-mute @DEFAULT_SINK@ toggle";
        "XF86AudioMicMute" = "exec pactl set-source-mute @DEFAULT_SOURCE@ toggle";
       # "XF86Launch1" = "exec ~/scripts/sunset.sh";
        "${modifier}+Control+p" = "exec i3lock -n -c ef5ffc";
        "${modifier}+Control+x" = "exec ~/scripts/scale.sh";
    };
    menu = "rofi -show drun";
    modifier = "Mod4";
    window.titlebar = false;
    terminal = "alacritty";
    window.border = 2;
    startup = [
      { command = "feh --bg-scale ~/.config/home-manager/xenia.png"; }
      { command = "keepassxc"; }
      { command = "i3-msg workspace 1"; }
    ];
  };
  services.redshift = {
    enable = true;
    latitude = 49.0;
    longitude = 9.0;
    tray = true;
  };
  services.caffeine.enable = true;
  services.screen-locker.enable = true;
  services.screen-locker.lockCmd = "/home/vi/.nix-profile/bin/i3lock -n -c ef5ffc";
  programs.i3status = {
    enable = true;
    enableDefault = false;
    general = {
      colors = true;
      interval = 5;
      color_good = "#333333";
      color_degraded = "#333333";
      color_bad = "#333333";
      color_separator = "#a15ffc";
      separator = " ★ ";
    };
    modules = {
      "volume master".position = 1;
      "wireless wlp2s0" = {
        position = 2;
        settings = {
          format_up = "%essid %bitrate";
          format_down = "down";
        };
      };
      "battery 0" = {
        position = 3;
        settings = {
          color_good = "#333333";
          color_degraded = "#d6cf19";
          color_bad = "#d6191f";
          format = "%status %percentage %remaining";
          status_chr = "C";
          status_bat = "B";
          status_full = "F";
        };
      };
      "time" = {
        position = 4;
        settings = {
          format = "%a, %d.%m.%Y - %H:%M ★ ";
        };
      };
    };
  };
}
