{ pkgs, lib, ... }:
{
  # This must appear before "column_meters_*" options
  xdg.configFile."htop/htoprc".text = lib.mkBefore ''
    header_layout=two_50_50
  '';
  home.packages = [ pkgs.htop ];
  programs.htop = {
    enable = lib.mkDefault true;
    settings = {
      account_guest_in_cpu_meter = false;
      all_branches_collapsed = false;
      color_scheme = false;
      column_meter_modes_0 = "3 1 1 1";
      column_meter_modes_1 = "2 2 2 3 1 3 1 1 1 1";
      column_meters_0 = "AllCPUs Memory Swap Zram";
      column_meters_1 = "Systemd LoadAverage Uptime DiskIO DiskIO NetworkIO NetworkIO ZFSARC ZFSCARC PressureStallIOFull";
      cpu_count_from_one = false;
      degree_fahrenheit = false;
      delay = 15;
      detailed_cpu_time = true;
      enable_mouse = true;
      find_comm_in_cmdline = true;
      header_margin = true;
      hide_function_bar = false;
      hide_kernel_threads = false;
      hide_threads = true;
      hide_userland_threads = true;
      highlight_base_name = true;
      highlight_changes = true;
      highlight_changes_delay_secs = 5;
      highlight_deleted_exe = true;
      highlight_megabytes = true;
      highlight_threads = true;
      screen_tabs = true;
      shadow_other_users = false;
      show_cpu_frequency = true;
      show_cpu_temperature = false;
      show_cpu_usage = true;
      show_merged_command = false;
      show_program_path = false;
      show_thread_names = false;
      sort_direction = 0;
      sort_key = 46; # PERCENT_CPU
      strip_exe_from_cmdline = true;
      tree_sort_direction = 0;
      tree_sort_key = 46; # PERCENT_CPU
      tree_view = true;
      tree_view_always_by_pid = false;
      update_process_names = false;
      /*
        "screen:Main" = ''
      PID USER PRIORITY NICE M_VIRT M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command
      .sort_key=PERCENT_CPU
      .tree_sort_key=PERCENT_CPU
      .tree_view=1
      .tree_view_always_by_pid=0
      .sort_direction=0
      .tree_sort_direction=0
      .all_branches_collapsed=0
        '';
        "screen:I/O" = ''
      PID USER IO_PRIORITY IO_RATE IO_READ_RATE IO_WRITE_RATE
      .sort_key=IO_RATE
      .tree_sort_key=PID
      .tree_view=0
      .tree_view_always_by_pid=0
      .sort_direction=-1
      .tree_sort_direction=1
      .all_branches_collapsed=0
        '';
      */
    };
  };
}