aboutsummaryrefslogtreecommitdiffstats
path: root/home/sadbeast/features/desktop/sway.nix
blob: 012f6f94ec8130e339dbb309aa99f2bb0e1cb1e1 (plain) (blame)
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
{
  config,
  lib,
  pkgs,
  ...
}: {
  fonts.fontconfig.enable = true;

  home = {
    sessionVariables = {
      XDG_CURRENT_DESKTOP = "sway";
      MOZ_ENABLE_WAYLAND = 1;
      QT_QPA_PLATFORM = "wayland";
      LIBSEAT_BACKEND = "logind";
      SDL_VIDEODRIVER = "wayland";
    };
    packages = with pkgs; [
      grim
      iosevka
      nerd-fonts.iosevka
      light
      slurp
      swayimg
      wl-clipboard
      dmenu-wayland
      xwayland
    ];

    pointerCursor = {
      gtk.enable = true;
      package = pkgs.vanilla-dmz;
      name = "Vanilla-DMZ";
      size = 22;
    };
  };

  gtk = {
    enable = true;
    theme = {
      package = pkgs.gnome-themes-extra;
      # name = "Adwaita-dark";
      name = "Adwaita";
    };
  };

  wayland.windowManager.sway = {
    enable = true;

    config = {
      modifier = "Mod4";

      bars = [];

      fonts = {
        names = ["Iosevka"];
        size = 10.0;
      };

      gaps = {
        smartGaps = true;
        outer = 0;
      };

      input = {
        "*" = {
          xkb_layout = "us";
          xkb_options = "ctrl:nocaps";
          tap = "enabled";
        };
      };

      keybindings = let
        modifier = config.wayland.windowManager.sway.config.modifier;
      in
        lib.mkOptionDefault {
          "${modifier}+p" = "exec passmenu";
          "${modifier}+Shift+Return" = "exec qutebrowser";
          "${modifier}+y" = "exec grim ~/scrn-$(date +\"%Y-%m-%d-%H-%M-%S\").png";
          "${modifier}+Shift+y" = "exec slurp | grim -g - ~/scrn-$(date +\"%Y-%m-%d-%H-%M-%S\").png";
          "XF86AudioRaiseVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%+ && wpctl get-volume @DEFAULT_AUDIO_SINK@ | sed 's/[^0-9]//g' > $XDG_RUNTIME_DIR/wob.sock";
          "XF86AudioLowerVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%- && wpctl get-volume @DEFAULT_AUDIO_SINK@ | sed 's/[^0-9]//g' > $XDG_RUNTIME_DIR/wob.sock";
          "XF86AudioMute" = "exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle && (wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -q MUTED && echo 0 > $XDG_RUNTIME_DIR/wob.sock) || wpctl get-volume @DEFAULT_AUDIO_SINK@ > $XDG_RUNTIME_DIR/wob.sock";

          "XF86MonBrightnessUp" = "exec light -A 5 && light -G | cut -d'.' -f1 > $XDG_RUNTIME_DIR/wob.sock";
          "XF86MonBrightnessDown" = "exec light -U 5 && light -G | cut -d'.' -f1 > $XDG_RUNTIME_DIR/wob.sock";
        };

      startup = [
        {
          command = "systemctl --user restart waybar";
          always = true;
        }
      ];

      terminal = "${pkgs.foot}/bin/foot";
    };

    extraConfig = ''
      # Window borders
      default_border pixel 1
      default_floating_border normal
      hide_edge_borders smart
    '';
  };

  programs = {
    swaylock.enable = true;
  };

  services = {
    mako = {
      enable = true;

      extraConfig = ''
        [mode=do-not-disturb]
        invisible=1
      '';
    };

    pasystray.enable = true;

    swayidle = {
      enable = true;

      events = [
        # { event = "timeout 300"; command = "${pkgs.swaylock}/bin/swaylock -fF -c 000000"; }
        # { event = "timeout 600"; command = "swaymsg \"output * dpms off\""; }
        {
          event = "after-resume";
          command = "swaymsg \"output * dpms on\"";
        }
        {
          event = "before-sleep";
          command = "${pkgs.swaylock}/bin/swaylock -fF -c 000000";
        }
      ];
    };
    wob.enable = true;
  };
}