~ruther/nixos-config

ref: f25ce880d7cd7b0e61a16bcfda57ef3752d8803d nixos-config/home/modules/profiles/desktop/dwl/default.nix -rw-r--r-- 7.7 KiB
f25ce880 — Frantisek Bohacek feat: add idle mode to mako to show notifications indefinitely when idle 8 months ago
                                                                                
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
{ lib, inputs, config, pkgs, ... }:

let
  # TODO save only those that are on in somewhere like tmp,
  # after enable is called, wake up only these if the file exists
  wlopmScreens = operation: pkgs.writeShellApplication {
    name = "wlopm-all-screens-${operation}";
    runtimeInputs = [
      pkgs.wlopm
      pkgs.gawk
      pkgs.findutils
    ];
    text = ''
      screens=$(wlopm | awk '{print $1}')
      echo "$screens" | xargs -l wlopm --${operation}
    '';
  };

  wlopmDisableScreens = wlopmScreens "off";
  wlopmEnableScreens = wlopmScreens "on";
in {
  imports = [
    ./mako.nix
    ./mako-hm-impl.nix
  ];

  options = {
    profiles.desktop.dwl = {
      enable = lib.mkEnableOption "dwl";
    };
  };

  config = lib.mkIf config.profiles.desktop.dwl.enable {
    profiles.desktop.enable = true;
    systemd.user.targets.wlr-session = {
      Unit = {
        Description = "A target that is enabled when starting Dwl";
        Requires = [ "graphical-session.target" "wm-services.target" ];
        PartOf = [ "graphical-session.target" ];
      };
    };

    home.file.".sessions/start-dwl".source = pkgs.writeShellScript "start-dwl" ''
      export XDG_CURRENT_DESKTOP=wlroots XDG_BACKEND=wayland QT_QPA_PLATFORM=wayland MOZ_ENABLE_WAYLAND=1 _JAVA_AWT_WM_NONREPARENTING=1
      dwl -s "${pkgs.writeShellScript "dwl-internal" ''
        exec <&-
        dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP DISPLAY
        systemctl start --user wlr-session.target
      ''}" &
      pid=$!
      # Put something here
      wait $pid
      systemctl stop --user graphical-session.target
    '';

    home.file.".sessions/start-dwl-temp".source = pkgs.writeShellScript "start-dwl-temp" ''
    export XDG_CURRENT_DESKTOP=wlroots XDG_BACKEND=wayland QT_QPA_PLATFORM=wayland MOZ_ENABLE_WAYLAND=1 _JAVA_AWT_WM_NONREPARENTING=1
        $HOME/doc/projects/mine/nix/dwm/result/bin/dwl -s "${pkgs.writeShellScript "dwl-internal" ''
          dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP DISPLAY
          systemctl start --user wlr-session.target
        ''}" &
      pid=$!
      # Put something here
      wait $pid
      systemctl stop --user graphical-session.target
    '';

    home.file.".config/dwl/scripts/brightness.sh".source = ../qtile/config/brightness.sh;
    home.file.".config/dwl/scripts/print.sh".source = pkgs.writeShellScript "print.sh" ''
      #!/bin/sh -e

      out="$HOME/screens/$(date +%Y/%Y%m%d_%H%M%S).png"

      while getopts o:s arg; do case $arg in
        o) out="$OPTARG" ;;
        s) sel="$(slurp -o)" ;;
        ?|*) echo "usage: shot [-s] [-o out]" >&2; exit 1 ;;
      esac; done

      grim ''${sel:+ -g "$sel"} "$out"
      echo "$out"
      wl-copy -t image/png < "$out"
    '';
    home.file.".config/dwl/sequence-detector.config.json".source = ../qtile/config/sequence-detector.config.json;

    home.packages = [
      # Clipboard
      pkgs.cliphist
      pkgs.wl-clipboard
      # PrintScreening
      pkgs.grim
      pkgs.slurp
      # pkgs.wldash
      pkgs.imv
      # DWL control
      inputs.self.packages.${pkgs.system}.dwlb
      inputs.self.packages.${pkgs.system}.dwlmsg
      pkgs.wlr-randr
      pkgs.wlrctl
      pkgs.wlopm
      pkgs.kanshi

      inputs.self.packages.${pkgs.system}.dwl
    ];

    programs = {
      swaylock = {
        enable = true;
        settings = {
          color = "808080";
          indicator-radius = 100;
          show-failed-attempts = true;
        };
      };
    };

    rutherther.programs.mako = {
      enable = true;

      config = with config.themes.default; {
        default = {
          font = "Ubuntu Mono 10";
          text-color = "#${foreground.text}FF";
          background-color = "#${background.primary}CC";

          border-size = 2;
          border-color = "#${foreground.active}FF";

          height = 250;
          margin = 5;
          padding = 24;
          max-icon-size = 16;
          layer = "overlay";

          default-timeout = 5000;
          ignore-timeout = 1;
        };

        sections = [
          {
            conditions = { mode = "idle"; };
            config = {
              border-color = "#${background.secondary}FF";
              ignore-timeout = 1;
              default-timeout = 0;
            };
          }

          {
            conditions = { urgency = "critical"; };
            config = {
              border-color = "#${urgent}FF";
            };
          }
        ];
      };
    };

    services.cliphist = {
      enable = true;
      systemdTarget = "wlr-session.target";
    };

    services.swayidle = {
      enable = true;
      events = [
        { event = "before-sleep"; command = "${lib.getExe pkgs.swaylock} -Ff"; }
        { event = "lock"; command = "${lib.getExe pkgs.swaylock} -Ff"; }
      ];
      timeouts = [
        { timeout = 300; command = lib.getExe wlopmDisableScreens; resumeCommand = lib.getExe wlopmEnableScreens; }
        { timeout = 1800; command = "${lib.getExe' pkgs.systemd "systemctl"} suspend"; }
        { timeout = 10; command = "${lib.getExe' pkgs.mako "makoctl"} mode -a idle"; resumeCommand = "${lib.getExe' pkgs.mako "makoctl"} mode -r idle"; }
      ];
    };

    xdg.portal = {
      enable = true;
      extraPortals = [
        pkgs.xdg-desktop-portal-wlr
        pkgs.xdg-desktop-portal-gtk
      ];
      config = {
        wlroots = {
          default = [ "gtk" "wlr" ];
          "org.freedesktop.impl.portal.ScreenCast" = "wlr";
          "org.freedesktop.impl.portal.Screenshot" = "wlr";
          # https://github.com/labwc/labwc/discussions/1503
          "org.freedesktop.impl.portal.Inhibit" = "none";
        };
      };
    };

    services.kanshi = {
      enable = true;
      systemdTarget = "wlr-session.target";
      settings = [
        {
          profile.name = "ntb";
          profile.outputs = [
            { criteria = "eDP-1"; status = "enable"; mode = "1920x1200"; position = "0,0"; }
          ];
        }
        {
          profile.name = "docked-1";
          profile.outputs = [
            { criteria = "DP-7"; position = "1920,0"; }
            { criteria = "DP-8"; position = "3840,0"; }
            { criteria = "DP-9"; position = "0,0"; }
            { criteria = "eDP-1"; status = "disable"; }
          ];
        }
        {
          profile.name = "docked-2";
          profile.outputs = [
            { criteria = "DP-10"; position = "1920,0"; }
            { criteria = "DP-11"; position = "3840,0"; }
            { criteria = "DP-12"; position = "0,0"; }
            { criteria = "eDP-1"; status = "disable"; }
          ];
        }
      ];
    };

    services.gammastep = {
      enable = true;
      temperature.night = 3000;
      latitude = 50.2332933;
      longitude = 14.3225926;
    };

    systemd.user.services.swayidle = {
      Install.WantedBy = lib.mkForce [ "wlr-session.target" ];
      Unit.PartOf = lib.mkForce [ "wlr-session.target" ];
    };

    systemd.user.services.gammastep = {
      Unit.After = lib.mkForce [ "wlr-session.target" ];
      Unit.PartOf = lib.mkForce [ "wlr-session.target" ];
      Install.WantedBy = lib.mkForce [ "wlr-session.target" ];
    };

    programs.waybar = {
      enable = true;
      package = pkgs.waybar.overrideAttrs (oldAttrs: {
        patches = (oldAttrs.patches or []) ++ [
          (pkgs.fetchpatch {
            url = "https://github.com/Rutherther/Waybar/commit/98b08880409cfd1277dc491b2f89de39a5107e50.patch";
            hash = "sha256-qnMnjL8ejGEO9SeIEclez1OISY7poKimr4Hu+ngKnxA=";
          })
        ];
      });
      systemd = {
        enable = true;
        target = "wlr-session.target";
      };
      style = ./waybar/style.css;
    };

    xdg.configFile."waybar/config.jsonc".source = ./waybar/config.jsonc;
    # xdg.configFile."waybar/style.css".source = ./waybar/style.css;

  };
}
Do not follow this link