about summary refs log tree commit diff
path: root/modules/user/sternenseemann/profiles/desktop-sway.nix
blob: a38ae03537f54a0d37a55d79a35aa4230471ab3f (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
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
# TODO(sterni) icons, GTK
# TODO(sterni) X11 cursor
{ config, pkgs, lib, ... }:

let
  cfg = config.vuizvui.user.sternenseemann.profiles.desktop-sway;

  inherit (pkgs.vuizvui.profpatsch)
    getBins
    ;

  inherit (pkgs.vuizvui.sternenseemann)
    tep
    ;

  bins = (getBins pkgs.bemenu [ "bemenu" "bemenu-run" ])
      // (getBins tep [ "tep" ])
      // (getBins pkgs.grim [ "grim" ])
      // (getBins pkgs.slurp [ "slurp" ])
      // (getBins pkgs.mako [ "makoctl" ])
      // (getBins screenshot [ "screenshot" ])
      // (getBins pkgs.foot [ "foot" ])
      // (getBins config.vuizvui.user.sternenseemann.programs.saneterm.package [ "saneterm" ])
      // (getBins pkgs.bash [ "sh" ])
      ;

  screenshot = pkgs.writers.writeDashBin "screenshot" ''
    if [ "$1" != "full" ]; then
      additionalOpts="-g '$(${bins.slurp})'"
    else
      shift
    fi

    $SHELL -c "${bins.grim} $additionalOpts $@"
  '';

  defaultFont = builtins.head config.fonts.fontconfig.defaultFonts.monospace;
  defaultEmojiFont = builtins.head config.fonts.fontconfig.defaultFonts.emoji;

  mkDefEnableOption = text: lib.mkEnableOption text // {
    default = true;
    example = false;
  };

in

{
  options = {
    vuizvui.user.sternenseemann.profiles.desktop-sway = {
      enable = lib.mkEnableOption "Sway-based Desktop Profile";
      saneterm.enable = mkDefEnableOption "Keyboard shortcuts for saneterm";
      tep.enable = mkDefEnableOption "Keyboard shortcuts for the tep emoji picker";
      nextcloud.enable = mkDefEnableOption "Automatically launching Nextcloud-Client";
      screenshot.enable = mkDefEnableOption "Keyboard shortcuts for taking screenshots";
    };
  };

  config = lib.mkIf cfg.enable (lib.mkMerge [
    # Core of the module, always active
    {
      vuizvui.user.sternenseemann.services.sway = {
        enable = true;
        additionalBinds = {
          "$mod+c" = "${bins.makoctl} dismiss -a";
        };
        term = bins.foot;
        menu = "${bins.bemenu-run} -l 10 -i";
        lockArgs = [
          "-c" "FFC0CB" "-k" "-l"
        ];
        font = {
          name = defaultFont;
          size = 10;
        };
      };

      # notifications
      services.dbus.packages = [ pkgs.mako ];

      environment.systemPackages = with pkgs; [
        bemenu                     # better dmenu
        xwayland qt5.qtwayland
        wl-clipboard               # instead of xsel
        mako                       # notifications
        gnome.adwaita-icon-theme
      ];

      programs.fish.shellAliases = {
        "hdmi2-above" = ''
          sway output HDMI-A-2 position 0 0 && sway output eDP-1 position 0 1440
        '';
        "workspace-move" = "sway move workspace output";
      };

      vuizvui.programs.foot = {
        enable = true;
        settings = {
          include = "${pkgs.foot.themes}/share/foot/themes/selenized-white";

          dpi-aware = true;
          font = [
            {
              font = defaultFont;
              options = { size = 8; };
            }
            {
              font = defaultEmojiFont;
              options = { size = 8; };
            }
          ];

          tweak = {
            grapheme-shaping = "yes";
          };

          key-bindings = {
            scrollback-up-page = "Control+Shift+Page_Up";
            scrollback-down-page = "Control+Shift+Page_Down";
            search-start = "Control+Shift+F";
            font-increase = "Control+Shift+b";
            font-decrease = "Control+Shift+t";
            font-reset = "Control+Shift+0";
            unicode-input = "none";
            show-urls-launch = "Control+Shift+u";
          };

          mouse-bindings = {
            primary-paste = "none";
          };

          mouse = {
            alternate-scroll-mode = "yes";
          };

          scrollback = {
            lines = 10000;
            indicator-position = "none";
          };
        };
      };
    }

    (lib.mkIf cfg.saneterm.enable {
      vuizvui.user.sternenseemann = {
        programs.saneterm.enable = true;
        services.sway.additionalBinds = {
          "$mod+Shift+Return" = "${bins.saneterm} -- ${bins.sh} -l";
        };
      };
    })

    (lib.mkIf cfg.nextcloud.enable {
      vuizvui.user.sternenseemann.services.sway.extraConfig = ''
        exec ${pkgs.gnome.gnome-keyring}/bin/gnome-keyring-daemon --start --components=secrets
        exec ${pkgs.nextcloud-client}/bin/nextcloud
      '';

      environment.systemPackages = [
        pkgs.nextcloud-client
      ];

      # so libsecret works
      services.gnome.gnome-keyring.enable = true;
      programs.dconf.enable = true;
    })

    (lib.mkIf cfg.tep.enable {
      vuizvui.user.sternenseemann.services.sway.additionalBinds = {
        "$mod+g" = "${bins.tep} copy -l 25 -p 'tep>' -i";
      };
    })

    (lib.mkIf cfg.screenshot.enable {
      vuizvui.user.sternenseemann.services.sway.additionalBinds = {
        "$mod+x" = bins.screenshot;
      };
      environment.systemPackages = [
        pkgs.grim pkgs.slurp screenshot      # screenshots
      ];
    })
  ]);
}