about summary refs log tree commit diff
path: root/home/profiles/gui/default.nix
blob: edc164685f58dff17dc8571d9561e490ef5d252f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
{ config, lib, inputs, pkgs, self, ... }:
let
  cfg = config.profiles.gui;

  neotheme = config.neotheme;
in
{
  imports = [
    ../../modules/misc/neotheme
  ];

  options.profiles.gui = {
    enable = lib.mkEnableOption
      "The gui profile, sets up sway and related applications.";

    laptop.enable = lib.mkEnableOption
      "Enable laptop-specific tweaks";

    font = {
      name = lib.mkOption {
        type = lib.types.str;
        default = "Dina";
        description = "Name of the primary font";
      };

      size = lib.mkOption {
        type = lib.types.number;
        default = 10;
        description = "Size for the primary font";
      };

      pixelSize = lib.mkOption {
        type = lib.types.number;
        default = 13;
        description = "Pixelsize(px) for the primary font";
      };
    };
  };

  config = lib.mkIf cfg.enable {
    gtk.enable = true;
    gtk.iconTheme.package = pkgs.papirus-icon-theme;
    gtk.iconTheme.name = "Papirus-Dark";
    gtk.theme.package = (pkgs.orchis-theme.override { tweaks = [ "primary" "compact" ]; });
    gtk.theme.name = "Orchis-dark-compact";
    gtk.font.name = "${cfg.font.name} ${toString cfg.font.size}";

    home.file.".icons/default".source = "${pkgs.vanilla-dmz}/share/icons/Vanilla-DMZ-AA";

    neotheme = {
      name = "Softjelly";
      identifier = "softjelly";

      colors = {
        background = "151515";
        foreground = "cbc0ab";
        alt0 = "404040";
        alt1 = "606060";
        color0 = "3c3c3c";
        color1 = "cf6a4c";
        color2 = "99ad6a";
        color3 = "dfa358";
        color4 = "8197bf";
        color5 = "b3a3ff";
        color6 = "8fbfdc";
        color7 = "cbc0ab";
        bright0 = "4c4c4c";
        bright1 = "d98870";
        bright2 = "adbd88";
        bright3 = "e5b579";
        bright4 = "9aaccc";
        bright5 = "c2b5ff";
        bright6 = "a5cce3";
        bright7 = "d5cdbc";
      };
    };

    home.packages = [
      # Sway
      pkgs.autotiling
      pkgs.swaybg
      pkgs.wayland-utils
      pkgs.wl-clipboard
      pkgs.grim
      pkgs.slurp
      pkgs.sway-contrib.grimshot
      pkgs.waybar
      pkgs.bemenu
      pkgs.qt5.qtwayland
      pkgs.xdg-utils

      # Fix gpg not recognizing foot terminfo
      pkgs.foot.terminfo
    ];

    home.sessionVariables = {
      NIXOS_OZONE_WL = 1; # NOTE: might cause problems with old electron
      _JAVA_AWT_WM_NONREPARENTING = "1"; # Fix 'grey screen' issue on java apps
    };

    wayland.windowManager.sway = {
      enable = true;

      wrapperFeatures = {
        base = true;
        gtk = true;
      };

      config = {
        bars = [{ command = "${pkgs.waybar}/bin/waybar"; }];
        keybindings = { };
      };

      extraSessionCommands = ''
        . "${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh"
      '';

      extraConfig = import ./config/sway.nix { inherit config pkgs neotheme; };
    };

    i18n.inputMethod.enabled = "fcitx5";
    i18n.inputMethod.fcitx5.addons = with pkgs; [
      fcitx5-gtk
      fcitx5-mozc
    ];

    programs = {
      foot = {
        enable = true;

        settings = import ./config/foot.nix { inherit config neotheme; };
      };

      waybar = {
        enable = config.wayland.windowManager.sway.enable;

        settings = [ (import ./config/waybar/settings.nix { inherit config lib neotheme; }) ];

        style = import ./config/waybar/style.nix { inherit config neotheme; };
      };
    };

    services = {
      dunst = {
        enable = true;
        settings = import ./config/dunst.nix { inherit config neotheme; };
      };

      kanshi = {
        enable = true;
        profiles = {
          haruka-standalone = {
            outputs = [
              {
                criteria = "AU Optronics 0xD291 Unknown";
                scale = 1.25;
              }
            ];
          };
        };
      };

      swayidle =
        let
          # TODO: remove when >1.6.11
          # Fixes frequent RSOD
          swaylock-effects = pkgs.swaylock-effects.overrideAttrs {
            src = pkgs.fetchFromGitHub {
              owner = "jirutka";
              repo = "swaylock-effects";
              rev = "7c5681ce96587ce3090c6698501faeccdfdc157d";
              sha256 = "sha256-09Kq90wIIF9lPjiY2anf9MSgi/EqeXKXW1mFmhxA/aM=";
            };
          };
          lockCommand = ''${swaylock-effects}/bin/swaylock \
            --daemonize \
            --screenshots \
            --color ${neotheme.colors.background} \
            --clock \
            --indicator \
            --show-failed-attempts \
            --effect-blur 7x5 \
            --effect-vignette 0.5:0.5 \
            --fade-in 0.2'';
        in
        {
          enable = true;
          events = [
            { event = "before-sleep"; command = lockCommand; }
            { event = "lock"; command = lockCommand; }
          ];
          timeouts = [
            # 4m30s
            { timeout = 270; command = "${pkgs.libnotify}/bin/notify-send -t 30000 'Locking screen in 30 seconds'"; }
            # 5m
            { timeout = 300; command = lockCommand; }
            # 10m
            {
              timeout = 600;
              command = "${pkgs.sway}/bin/swaymsg 'output * dpms off'";
              resumeCommand = "${pkgs.sway}/bin/swaymsg 'output * dpms on'";
            }
            # 15m
            {
              timeout = 900;
              command = "${pkgs.systemd}/bin/systemctl suspend";
            }
          ];
        };

      wlsunset = {
        enable = true;
        latitude = "36.5";
        longitude = "127.2";
      };
    };
  };
}