aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/modules/workstation/ui/i3/core/setup.nix
blob: 76b4b61ac696e85a591f600704e0833be6b8c6f6 (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
/** Main entry point for the home-manager module configuration
 *
 * For some reason, access to the config.libkookie.* option tree
 * is not possible here, but instead needs to be deferred to an
 * imported expression.  For that reason, this file only contains
 * key allocations, and no actual configuration content.
 */

{ config, lib, pkgs, home-manager, ... } @ args:

let cfg = config.libkookie.ui.i3;
in
{
  xsession.windowManager.i3 =
    let config = (import ./config.nix args);
    in
      {
        enable = true;
        package = pkgs.i3;
        inherit config;

        # TODO: move this into the config module?

        extraConfig = with pkgs;
          let
            fehCmd = "${feh}/bin/feh --bg-fill ${cfg.wallpaper}";
            picomCmd = "";
            nmCmd = if cfg.networkmanager
                    then "exec_always --no-startup-id ${networkmanagerapplet}/bin/nm-applet"
                    else "";
          in
            ''
              # Setup compositor // TODO: gate this on the hm-module
              exec_always --no-startup-id "${coreutils}/bin/pkill picom; ${picom}/bin/picom --config ~/.config/i3/picom.conf"
          
              # Make CAPSLOCK into ESC because it's 2018
              #
              # Okay actually this is slightly more complicated than that. I'm binding 
              # CAPSLOCK to HYPER, so that I can use it as a modifier in emacs, but then 
              # using xcape(1) to also make short CAPSLOCK presses into ESCAPE.
    
              exec_always --no-startup-id "${xorg.xmodmap}/bin/setxkbmap -layout us -variant altgr-intl -option caps:hyper"
              exec ${xcape}/bin/xcape -e "#66=Escape" -t 150
    
              # Set the desired wallpaper
              exec_always --no-startup-id ${fehCmd}
    
              # Start nm-applet if networkmanager is enabled
              ${nmCmd}
    
              bar {
                  status_command ${i3status}/bin/i3status -c ~/.config/i3/i3status.conf
                  position bottom
                  bindsym button4 nop
                  bindsym button5 nop
                  colors  {
                      background #0F0F0F
                      statusline #D5D5D5
                  }
              }
    
              focus_follows_mouse no
    
              # Layout and design settings that should _really_ be in the module
              default_border pixel 3
              client.focused #4c7899 #285577 #ffffff #F73E5F #666666
            '';
      };

  xdg.configFile."i3/picom.conf" = (import ./picom.nix args);

  xdg.configFile."i3/i3status.conf" = (import ./i3status.nix args);
}