ctucx.git: nixfiles

ctucx' nixfiles

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 
{ config, pkgs, lib, ... }:

let
  cfg = config.ctucxConfig.wm.sway;

in {

  options = {
    ctucxConfig.wm.sway  = {
      enable = lib.mkEnableOption "swaywm";
    };
  };

  config = lib.mkIf cfg.enable {
    nixpkgs.overlays = [(self: super: {

      wlroots = super.wlroots.overrideAttrs (old: {
        mesonFlags = (old.mesonFlags or []) ++ [
          "-Dxwayland=disabled"
        ];
      });

      sway-unwrapped = super.sway-unwrapped.overrideAttrs (old: {
        mesonFlags = (old.mesonFlags or []) ++ [
          "-Dxwayland=disabled"
        ];
      });

      xsel  = super.wl-clipboard-x11;
      xclip = super.wl-clipboard-x11;

    })];

    

    xdg.portal = {
      config.common.default = [ "wlr" ];
      wlr.enable = true;
    };

    home-manager.users.katja = {

      home.packages = with pkgs; [
        qt5.qtwayland wl-clipboard
      ];

      programs.bash.initExtra = ''
        if [ "$(tty)" = "/dev/tty1" ]; then
          exec sway
        fi
      '';

      wayland.windowManager.sway = let
        cfg         = config.home-manager.users.katja.wayland.windowManager.sway;
        modifier    = cfg.config.modifier;

      in {
        enable              = true;
        systemd.enable      = true;

        xwayland            = false;
        wrapperFeatures.gtk = true;

        extraSessionCommands = ''
          export QT_QPA_PLATFORM=wayland
          export QT_WAYLAND_FORCE_DPI=physical
          export QT_WAYLAND_DISABLE_WINDOWDECORATION=1

          export _JAVA_AWT_WM_NONREPARENTING=1

          # be careful with those, they *will* break some applications
          export SDL_VIDEODRIVER=wayland
          export GDK_BACKEND=wayland
        '';

        extraConfig = ''
          # Import the most important environment variables into the D-Bus and systemd
          # user environments (e.g. required for screen sharing and Pinentry prompts):
          exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
        '';

        config = {
          fonts = {
            names = [ "Noto Sans Mono" "FontAwesome5Free" ];
            style = "";
            size  = 11.0;
          };

          colors = {
            focused = {
              background  = "#3b8756";
              border      = "#3b8756";
              childBorder = "#3b8756";
              text        = "#eceff4";
              indicator   = "#8fbcbb";
            };
          };

          window = {
            titlebar        = false;
            hideEdgeBorders = "smart";
            border          = 5;
          };

          input = {

            "*" = {
              xkb_layout     = "us,ru,de";
              xkb_variant    = "mac,mac,qwerty";
              xkb_options    = "grp:alt_shift_toggle";
              natural_scroll = "enabled";
            };

            "1046:9110:Goodix_Capacitive_TouchScreen" = {
              map_to_output  = "DSI-1";
            };

            "1452:613:Apple_Inc._Magic_Trackpad_2" = {
              accel_profile = "adaptive";
            };

          };

          output = {

            "DSI-1" = {
              transform = "90";
              scale = "1.2";
            }; 

            "*" = {
#              bg = "~/Pictures/photos.ctu.cx/Bahnbilder/2019.06/20190622-153441.jpg fill";
              scale = lib.mkDefault "1";
            };

          };

      		assigns = {
      		  "1: Web"  = [{ app_id = "firefox"; }];
      		  "2: Mail" = [{ app_id = "thunderbird"; }];
      		};

          bars = [];

          modifier = "Mod4";

          workspaceAutoBackAndForth = true;

          keybindings = {
            "${modifier}+Return"        = "exec ${cfg.config.terminal}";
            "${modifier}+Space"         = "exec ${pkgs.wofi}/bin/wofi --style ${./wofi/style.css} --conf ${./wofi/config} --show drun";
            "${modifier}+l"             = "exec ${pkgs.systemd}/bin/loginctl lock-session";
            "${modifier}+z"             = "exec sleep 1 && systemctl suspend";
            "${modifier}+Tab"           = "exec ${pkgs.rofi-wayland}/bin/rofi -show wifi -modi 'wifi:${pkgs.rofi-iwd-wifi-menu}/bin/iwdrofimenu'";


            "${modifier}+Control+Print"         = "exec ${pkgs.grim}/bin/grim ~/Pictures/Screenshots/$(date +\"%Y-%m-%d_%H:%m:%S\").png";
            "${modifier}+Control+Shift+Print"   = "exec ${pkgs.grim}/bin/grim - | ${pkgs.wl-clipboard}/bin/wl-copy -t image/png";
            "${modifier}+Print"                 = "exec ${pkgs.grim}/bin/grim -g \"$(${pkgs.slurp}/bin/slurp)\" ~/Pictures/Screenshots/$(date +\"%Y-%m-%d_%H:%m:%S\").png";
            "${modifier}+Shift+Print"           = "exec ${pkgs.grim}/bin/grim -g \"$(${pkgs.slurp}/bin/slurp)\" - | ${pkgs.wl-clipboard}/bin/wl-copy -t image/png";

            "XF86MonBrightnessUp"       = "exec ${pkgs.brightnessctl}/bin/brightnessctl s +5%";
            "XF86MonBrightnessDown"     = "exec ${pkgs.brightnessctl}/bin/brightnessctl s 5%-";

            "XF86AudioRaiseVolume"      = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +5%";
            "XF86AudioLowerVolume"      = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -5%";
            "XF86AudioMute"             = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle";
            "XF86AudioMicMute"          = "exec ${pkgs.pulseaudio}/bin/pactl set-source-mute @DEFAULT_SOURCE@ toggle";

  	        "XF86AudioPlay"             = "exec ${pkgs.playerctl}/bin/playerctl play-pause";
            "XF86AudioNext"             = "exec ${pkgs.playerctl}/bin/playerctl next";
            "XF86AudioPrev"             = "exec ${pkgs.playerctl}/bin/playerctl previous";

            "${modifier}+Shift+e"       = "exec swaynag -t warning -m 'Do you really want to exit sway?' -b 'Yep' 'swaymsg exit'";

            "${modifier}+q"             = "kill";

            "${modifier}+Shift+c"       = "reload";

            "${modifier}+Left"          = "focus left";
            "${modifier}+Down"          = "focus down";
            "${modifier}+Up"            = "focus up";
            "${modifier}+Right"         = "focus right";
            "${modifier}+a"             = "focus parent";


            "${modifier}+Shift+Left"    = "move left";
            "${modifier}+Shift+Down"    = "move down";
            "${modifier}+Shift+Up"      = "move up";
            "${modifier}+Shift+Right"   = "move right";

            "${modifier}+1"             = "workspace 1: Web";
            "${modifier}+2"             = "workspace 2: Mail";
            "${modifier}+3"             = "workspace 3: Term; layout tabbed";
            "${modifier}+4"             = "workspace 4: Files";
            "${modifier}+5"             = "workspace number 5";
            "${modifier}+6"             = "workspace number 6";
            "${modifier}+7"             = "workspace number 7";
            "${modifier}+8"             = "workspace number 8";
            "${modifier}+9"             = "workspace number 9";
            "${modifier}+0"             = "workspace number 10";

            "${modifier}+Shift+1"       = "move container to workspace 1: Web";
            "${modifier}+Shift+2"       = "move container to workspace 2: Mail";
            "${modifier}+Shift+3"       = "move container to workspace 3: Term";
            "${modifier}+Shift+4"       = "move container to workspace 4: Files";
            "${modifier}+Shift+5"       = "move container to workspace number 5";
            "${modifier}+Shift+6"       = "move container to workspace number 6";
            "${modifier}+Shift+7"       = "move container to workspace number 7";
            "${modifier}+Shift+8"       = "move container to workspace number 8";
            "${modifier}+Shift+9"       = "move container to workspace number 9";
            "${modifier}+Shift+0"       = "move container to workspace number 10";

            "${modifier}+s"             = "layout stacking";
            "${modifier}+w"             = "layout tabbed";
            "${modifier}+e"             = "layout toggle split";

            "${modifier}+f"             = "fullscreen";

            "${modifier}+r"             = "mode \"resize\"";
            "${modifier}+b"             = "mode \"waybar\"";

            "${modifier}+Shift+space"   = "floating toggle";
          };

          modes = {
            "resize" = {
              "Right"         = "resize shrink width 10px";
              "Left"          = "resize grow width 10px";
              "Down"          = "resize shrink height 10px";
              "Up"            = "resize grow height 10px";

              "Return"        = "mode \"default\"";
              "Escape"        = "mode \"default\"";
              "${modifier}+r" = "mode \"default\"";
            };

            "waybar" = {
              "space"         = "exec pkill -SIGUSR1 waybar";
              "r"             = "exec pkill -SIGUSR2 waybar";

              "Return"        = "mode \"default\"";
              "Escape"        = "mode \"default\"";
              "${modifier}+r" = "mode \"default\"";
            };
          };
        };
      };
    };
  };

}