summaryrefslogtreecommitdiff
path: root/nix_archive/nix/programs/sway.nix
blob: 1fa762a424c56bb637408ca278493bd1ceb6f3de (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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
{ config, lib, pkgs, ... }:
let
  loc = config.local;
  colo = loc.scheme;
in {
  services.xserver.videoDrivers = [ "modesetting" ];
  programs.sway = {
    enable = true;
    package = pkgs.swayfx;
    extraPackages = with pkgs; [
      libinput
      swaybg
      swayidle
      wl-clipboard
      libnotify
      bemenu
      slurp
      grim
      wf-recorder
      wlsunset
      xprop
      xset
      xrdb
      xrandr
    ];
  };
  local.scripts.imports = [
    "dbus-sway-environment"
    "dmenu-path"
    "dmenu-path0"
    "dmenu-emoji"
    "wlsunset-toggle"
    "screenshot"
  ];
  services.dbus.enable = true;
  security.polkit.enable = true;
  programs.dconf.enable = true;
  xdg.portal = {
    enable = true;
    wlr.enable = true;
    extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
  };
  xdg.icons.enable = true;
  #services.getty.autologinUser = "andrew";
  #services.greetd = {
  #  enable = false;
  #  settings = {
  #    vt=3;
  #    default_session = {
  #      command = "run-sway";
  #      user = "root";
  #    };
  #  };
  #};
  qt = {
    enable = true;
    platformTheme = "qt5ct"; # Also selects qt6ct.
    style = "adwaita";
  };
  home-manager.users.andrew = {
    home.sessionVariables = {
      MAIN_MONITOR="${loc.monitors.monitor1}";
      XDG_CURRENT_DESKTOP = "sway";
      MOZ_ENABLE_WAYLAND = "1";
      SDL_VIDEODRIVER = "wayland";
      GDK_BACKEND = "wayland,x11";
      QT_QPA_PLATFORM = "wayland;xcb";
      QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
      _JAVA_AWT_WM_NONREPARENTING = "1";
    };
    xresources.properties = {
      "*background" = "#${colo.background}";
      "*foreground" = "#${colo.foreground}";
      "*color0" = "#${colo.color0}";
      "*color1" = "#${colo.color1}";
      "*color2" = "#${colo.color2}";
      "*color3" = "#${colo.color3}";
      "*color4" = "#${colo.color4}";
      "*color5" = "#${colo.color5}";
      "*color6" = "#${colo.color6}";
      "*color7" = "#${colo.color7}";
      "*color8" = "#${colo.color8}";
      "*color9" = "#${colo.color9}";
      "*color10" = "#${colo.color10}";
      "*color11" = "#${colo.color11}";
      "*color12" = "#${colo.color12}";
      "*color13" = "#${colo.color13}";
      "*color14" = "#${colo.color14}";
      "*color15" = "#${colo.color15}";
    };
    gtk = let
      # *_shade_color is adjusted from black by default.
      extraCss3 = ''
        @define-color shade_color #${colo.background};
        @define-color scrollbar_outline_color #${colo.foreground};
        @define-color window_bg_color #${colo.background};
        @define-color window_fg_color #${colo.foreground};
        @define-color view_bg_color #${colo.background};
        @define-color view_fg_color #${colo.foreground};
        @define-color accent_bg_color #${colo.color4};
        @define-color accent_fg_color #${colo.background};
        @define-color accent_color #${colo.color4};
        @define-color headerbar_bg_color #${colo.background};
        @define-color headerbar_fg_color #${colo.foreground};
        @define-color headerbar_backdrop_color #${colo.background};
        @define-color headerbar_border_color #${colo.color6};
        @define-color secondary_headerbar_bg_color #${colo.background};
        @define-color secondary_headerbar_fg_color #${colo.foreground};
        @define-color secondary_headerbar_backdrop_color #${colo.background};
        @define-color secondary_headerbar_border_color #${colo.color5};
        @define-color thumbnail_bg_color #${colo.background};
        @define-color thumbnail_fg_color #${colo.foreground};
        @define-color card_bg_color #${colo.background};
        @define-color card_fg_color #${colo.foreground};
        @define-color popover_bg_color #${colo.background};
        @define-color popover_fg_color #${colo.foreground};
        @define-color dialog_bg_color #${colo.background};
        @define-color dialog_fg_color #${colo.foreground};
        @define-color panel_bg_color #${colo.background};
        @define-color panel_fg_color #${colo.foreground};
        @define-color sidebar_bg_color #${colo.background};
        @define-color sidebar_fg_color #${colo.foreground};
        @define-color sidebar_backdrop_color #${colo.background};
        @define-color sidebar_border_color #${colo.color5};
        @define-color secondary_sidebar_bg_color #${colo.background};
        @define-color secondary_sidebar_fg_color #${colo.foreground};
        @define-color secondary_sidebar_backdrop_color #${colo.background};
        @define-color secondary_sidebar_border_color #${colo.color6};
        @define-color warning_bg_color #${colo.color4};
        @define-color warning_fg_color #${colo.foreground};
        @define-color warning_color #${colo.color4};
        @define-color error_bg_color #${colo.color3};
        @define-color error_fg_color #${colo.foreground};
        @define-color error_color #${colo.color3};
        @define-color success_bg_color #${colo.color2};
        @define-color success_fg_color #${colo.background};
        @define-color success_color #${colo.color2};
        @define-color destructive_bg_color #${colo.color5};
        @define-color destructive_fg_color #${colo.background};
        @define-color destructive_color #${colo.color5};
      '';
      extraCss4 = ''
      '';
    in rec {
      enable = true;
      theme = {
        name = "adw-gtk3" + (if colo.lightness == "light" then "" else "-dark");
        package = pkgs.adw-gtk3;
      };
      gtk4.theme = theme;
      cursorTheme = {
        name = "WhiteSur-cursors";
      };
      #iconTheme = {
      #  name = "suru";
      #  package = pkgs.ubuntu-themes;
      #};
      gtk3.extraCss = extraCss3;
      gtk4.extraCss = extraCss3;
    };
    home.pointerCursor = {
      name = "WhiteSur-cursors";
      package = pkgs.whitesur-cursors;
    };
    wayland.windowManager.sway = {
      enable = true;
      systemd.enable = true;
      xwayland = true;
      wrapperFeatures = { base = true; gtk = true; };
      swaynag = {
        enable = true;
        settings = {
          "<config>" = {
            edge = "top";
            font = "${loc.ui-font.name} ${toString loc.ui-font.size}";
            background = "${colo.background}";
            border = "${colo.background}";
            text = "${colo.foreground}";
            button-text = "${colo.foreground}";
            button-background = "${colo.color6}";
            message-padding = 5;
            border-bottom-size = 1;
            details-border-size = 1;
            button-border-size = 1;
            button-gap = 3;
            button-dismiss-gap = 7;
            button-padding = 3;
            button-margin-right = 5;
          };
        };
      };
      config = rec {
        input = {
          "type:keyboard" = {
            repeat_rate = "45";
            repeat_delay = "220";
            xkb_options = "ctrl:nocaps";
          };
          "type:touchpad" = {
            natural_scroll = "enabled";
          };
          "1189:32769:BenQ_ZOWIE_BenQ_ZOWIE_Gaming_Mouse" = {
            accel_profile = "flat";
            pointer_accel = "-0.675";
            scroll_factor = "1.0";
          };
          "1241:44368:USB_Gaming_Mouse" = { # Finalmouse Ultralight 2
            accel_profile = "flat";
            scroll_factor = "0.75";
          };
          "1133:45104:Logi_POP_Mouse" = {
            accel_profile = "flat";
            scroll_factor = "0.75";
          };
          "1133:50504:Logitech_USB_Receiver_Mouse" = {
            accel_profile = "flat";
            scroll_factor = "0.75";
          };
          "2362:9488:PixArt_USB_Optical_Mouse" = {
            accel_profile = "flat";
            scroll_factor = "0.75";
          };
          "1390:268:ELECOM_TrackBall_Mouse_HUGE_TrackBall" = {
            accel_profile = "flat";
            scroll_factor = "0.25";
            scroll_method = "on_button_down";
            scroll_button = "276";
          };
          "1386:890:Wacom_One_by_Wacom_S_Pen" = {
            map_to_output = loc.monitors.monitor1;
            left_handed = "enabled";
          };
        };
        modifier = "Mod1";
        menu = "dmenu-path | bemenu-colored | ${pkgs.findutils}/bin/xargs swaymsg exec --";
        focus.wrapping = "yes";
        keybindings = let
          mod1 = "Mod1";
        in {
          "button4" = "nop";
          "button5" = "nop";
          "${mod1}+d" = "exec ${menu}";
          "${mod1}+e" = "exec dmenu-emoji | bemenu-colored | awk '{split($0,a);printf \"%s\", a[1];}' | wl-copy";
          "${mod1}+q" = "exec screenshot qrcode";
          "${mod1}+c" = "exec screenshot color";
          "${mod1}+Shift+q" = "kill";
          "${mod1}+h" = "focus left";
          "${mod1}+j" = "focus down";
          "${mod1}+k" = "focus up";
          "${mod1}+l" = "focus right";
          "${mod1}+Shift+h" = "move left";
          "${mod1}+Shift+j" = "move down";
          "${mod1}+Shift+k" = "move up";
          "${mod1}+Shift+l" = "move right";
          "${mod1}+b" = "split h";
          "${mod1}+v" = "split v";
          "${mod1}+f" = "fullscreen toggle";
          "${mod1}+space" = "floating toggle";
          "${mod1}+r" = "mode \"resize\"";
          "${mod1}+Shift+c" = "reload";
          "${mod1}+Shift+e" = "exec swaynag -m 'Do you really want to exit?' -B 'Yes' 'swaymsg exit'";
          "Print" = "exec screenshot main";
          "Shift+Print" = "exec screenshot full";
          "${mod1}+Shift+s" = "exec screenshot";
          "${mod1}+s" = "exec wlsunset-toggle";
          "${mod1}+Shift+t" = "exec swaymsg -- input 1386:890:Wacom_One_by_Wacom_S_Pen events disabled";
        };
        modes = {
          resize = {
            Escape = "mode default";
            h = "resize shrink width 1 px";
            j = "resize grow height 1 px";
            k = "resize shrink height 1 px";
            l = "resize grow width 1 px";
          };
        };
        fonts = {
          names = [ loc.ui-font.name ];
          style = "Regular";
          size = loc.ui-font.size + 0.0;
        };
        bars = [ ];
        window = {
          border = 2;
          titlebar = false;
          commands = [
            { command = "move to scratchpad"; criteria.app_id = "kitty-server"; }
            { command = "allow_tearing yes"; criteria.app_id = "kitty"; }
            { command = "inhibit_idle fullscreen; floating enable"; criteria.app_id = "cmv"; }
            { command = "floating enable"; criteria.class = "cmv.exe"; }
            { command = "floating enable"; criteria.app_id = "mauri"; }
            { command = "inhibit_idle fullscreen"; criteria.title = "Parsec"; }
            { command = "inhibit_idle fullscreen"; criteria.class = "streaming_client"; }
            { command = "inhibit_idle fullscreen; allow_tearing yes"; criteria.class = "steam_app_.*"; }
            { command = "inhibit_idle fullscreen; allow_tearing yes; floating enable"; criteria.app_id = "gamescope"; }
            { command = "inhibit_idle fullscreen; allow_tearing yes"; criteria.class = ".gamescope-wrapped"; }
            { command = "inhibit_idle fullscreen; allow_tearing yes"; criteria.app_id = "osu!"; }
            { command = "inhibit_idle fullscreen; allow_tearing yes"; criteria.class = "cs2"; }
            { command = "inhibit_idle fullscreen; allow_tearing yes"; criteria.class = "Minecraft*"; }
            { command = "inhibit_idle fullscreen; allow_tearing yes"; criteria.title = "Overwatch"; }
            { command = "inhibit_idle fullscreen"; criteria.class = "Ryujinx"; }
            { command = "inhibit_idle fullscreen"; criteria.app_id = "org.yuzu_emu.yuzu"; }
            { command = "inhibit_idle fullscreen"; criteria.app_id = "info.cemu.Cemu"; }
            { command = "inhibit_idle fullscreen"; criteria.class = "dolphin-emu"; }
            { command = "inhibit_idle fullscreen"; criteria.class = "AppRun"; } # Ishiiruka-Dolphin
            { command = "inhibit_idle fullscreen"; criteria.class = "SuperMeatBoy"; }
          ];
        };
        colors = let
          bg = "#${colo.background}";
          fg = "#${colo.foreground}";
          ch = "#${colo.color4}";
          urgent = "#${colo.color1}";
        in {
          background = bg;
          focused = { background = bg; border = ch; childBorder = ch; indicator = ch; text = fg; };
          focusedInactive = { background = bg; border = ch; childBorder = ch; indicator = ch; text = fg; };
          unfocused = { background = bg; border = bg; childBorder = bg; indicator = bg; text = fg; };
          urgent = { background = urgent; border = urgent; childBorder = urgent; indicator = urgent; text = fg; };
          placeholder = { background = bg; border = bg; childBorder = bg; indicator = bg; text = fg; };
        };
        startup = let
          gnome-schema = "org.gnome.desktop.interface";
        in [
          { command = "dconf write /org/gnome/desktop/interface/color-scheme \"'prefer-${colo.lightness}'\""; always = true; }
          { command = "dbus-sway-environment"; }
          { command = "swaymsg 'seat * hide_cursor 4000'"; always = true; }
          { command = "kitty -1 --class=\"kitty-server\""; }
          { command = "wlsunset-toggle"; }
        ];
      };
#      extraConfig = ''
#        blur enable
#        blur_passes 4
#        blur_radius 2
#        blur_contrast 1.5
#        blur_saturation 1.1
#      '';
    };
    services.swayidle = {
      enable = true;
      timeouts = [
        {
          timeout = 300;
          command = "${pkgs.sway}/bin/swaymsg \"output * dpms off\"";
          resumeCommand = "${pkgs.sway}/bin/swaymsg \"output * dpms on\"";
        }
      ];
    };
    services.mako = {
      enable = true;
      settings = {
        default-timeout = 14000;
        font = "${loc.font.name} ${toString loc.ui-font.size}";
        background-color = "#${colo.background}";
        text-color = "#${colo.foreground}";
        border-color = "#${colo.color6}";
      };
    };
  };
}