summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/niri/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/gkleen@sif/niri/default.nix')
-rw-r--r--accounts/gkleen@sif/niri/default.nix289
1 files changed, 0 insertions, 289 deletions
diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix
deleted file mode 100644
index 6aa4391c..00000000
--- a/accounts/gkleen@sif/niri/default.nix
+++ /dev/null
@@ -1,289 +0,0 @@
1{ config, hostConfig, pkgs, lib, ... }:
2let
3 niri = config.programs.niri.package;
4 terminal = lib.getExe config.programs.kitty.package;
5 lightctl = lib.getExe' config.services.avizo.package "lightctl";
6 volumectl = lib.getExe' config.services.avizo.package "volumectl";
7 dunstctl = lib.getExe' config.services.dunst.package "dunstctl";
8 loginctl = lib.getExe' hostConfig.systemd.package "loginctl";
9 systemctl = lib.getExe' hostConfig.systemd.package "systemctl";
10
11 focus-or-spawn = pkgs.writeShellApplication {
12 name = "focus-or-spawn";
13 runtimeInputs = [ niri pkgs.gojq pkgs.gnugrep pkgs.socat ];
14 text = ''
15 app_id="$1"
16 shift
17 workspace_name="$1"
18 shift
19
20 workspaces_json="$(niri msg -j workspaces)"
21 workspace_output="$(jq -r --arg workspace_name "$workspace_name" '.[] | select(.name == $workspace_name) | .output' <<<"$workspaces_json")"
22 active_workspace="$(jq -r --arg workspace_output "$workspace_output" '.[] | select(.output == $workspace_output and .is_active) | .id' <<<"$workspaces_json")"
23 niri msg action move-workspace-to-monitor --output "$(jq -r '.[] | select(.is_focused) | .output' <<<"$workspaces_json")" "$workspace_name"
24 socat STDIO "$NIRI_SOCKET" <<<'{"Action":{"FocusWorkspace":{"reference":{"Id":'"''${active_workspace}"'}}}}'
25 niri msg action move-workspace-to-index --index 1 "$workspace_name"
26
27 while IFS=$'\n' read -r window_json; do
28 if jq -r '.app_id' <<<"$window_json" | grep -q "$app_id"; then
29 niri msg action focus-window --id "$(jq -r '.id' <<<"$window_json")"
30 exit 0
31 fi
32 done < <(niri msg -j windows | jq -c '.[]')
33
34 exec "$@"
35 '';
36 };
37 focus-or-spawn-action = app_id: workspace_name: config.lib.niri.actions.spawn (lib.getExe focus-or-spawn) (lib.escapeShellArg app_id) (lib.escapeShellArg workspace_name);
38in {
39 imports = [
40 ./waybar.nix
41 ];
42
43 config = {
44 systemd.user.services.xwayland-satellite = {
45 Unit = {
46 BindsTo = [ "graphical-session.target" ];
47 PartOf = [ "graphical-session.target" ];
48 After = [ "graphical-session.target" ];
49 Requisite = [ "graphical-session.target" ];
50 };
51 Service = {
52 Type = "notify";
53 NotifyAccess = "all";
54 Environment = [ "DISPLAY=:0" ];
55 ExecStart = ''${lib.getExe pkgs.xwayland-satellite-unstable} ''${DISPLAY}'';
56 ExecStartPre = "${systemctl} --user import-environment DISPLAY";
57 StandardOutput = "journal";
58 };
59 Install = {
60 WantedBy = [ "graphical-session.target" ];
61 };
62 };
63
64 services.swayidle = {
65 events = [
66 { event = "after-resume"; command = "${lib.getExe niri} msg action power-on-monitors"; }
67 ];
68 timeouts = [
69 { timeout = 300;
70 command = "${lib.getExe niri} msg action power-off-monitors";
71 }
72 ];
73 };
74
75 programs.niri.settings = {
76 prefer-no-csd = true;
77 screenshot-path = "${config.home.homeDirectory}/screenshots";
78
79 hotkey-overlay.skip-at-startup = true;
80
81 input = {
82 keyboard.xkb = {
83 layout = "us,us";
84 variant = "dvp,";
85 options = "compose:caps,grp:win_space_toggle";
86 };
87
88 workspace-auto-back-and-forth = true;
89 # focus-follows-mouse.enable = true;
90 warp-mouse-to-focus = true;
91 };
92
93 outputs = {
94 "Samsung Display Corp. 0x4141 Unknown" = {
95 scale = 1.5;
96 position = { x = 0; y = 0; };
97 };
98 "Ancor Communications Inc ASUS PB287Q 0x0000DD9B" = {
99 scale = 1.5;
100 position = { x = 2560; y = 0; };
101 };
102 };
103
104 environment = {
105 NIXOS_OZONE_WL = "1";
106 QT_QPA_PLATFORM = "wayland";
107 GDK_BACKEND = "wayland";
108 SDL_VIDEODRIVER = "wayland";
109 };
110
111 layout = {
112 gaps = 8;
113 struts = { left = 8; right = 8; top = 0; bottom = 0; };
114 focus-ring = {
115 width = 2;
116 };
117 };
118
119 cursor.hide-when-typing = true;
120
121 workspaces = {
122 "001".name = "pwctl";
123 "002".name = "kpxc";
124 "003".name = "bmgr";
125 "101".name = "comm";
126 "102".name = "web";
127 "104".name = "read";
128 "105".name = "mon";
129 "110".name = "vid";
130 };
131
132 window-rules = [
133 {
134 geometry-corner-radius =
135 let
136 allCorners = r: { bottom-left = r; bottom-right = r; top-left = r; top-right = r; };
137 in allCorners 8.;
138 clip-to-geometry = true;
139 }
140 {
141 matches = [ { app-id = "^com\.saivert\.pwvucontrol$"; } ];
142 open-on-workspace = "pwctl";
143 }
144 {
145 matches = [ { app-id = "^\.blueman-manager-wrapped$"; } ];
146 open-on-workspace = "bmgr";
147 }
148 {
149 matches = [ { app-id = "^org\.keepassxc\.KeePassXC$"; } ];
150 excludes = [
151 { title = "^Unlock Database"; }
152 { title = "^Access Request"; }
153 { title = "^Passkey credentials"; }
154 ];
155 open-on-workspace = "kpxc";
156 open-focused = false;
157 }
158 {
159 matches = [
160 { app-id = "^thunderbird$"; }
161 { app-id = "^Element$"; }
162 ];
163 open-on-workspace = "comm";
164 }
165 {
166 matches = [ { app-id = "^firefox$"; } ];
167 open-on-workspace = "web";
168 }
169 {
170 matches = [
171 { app-id = "^evince$"; }
172 { app-id = "^imv$"; }
173 { app-id = "^org\.pwmt\.zathura$"; }
174 ];
175 open-on-workspace = "read";
176 }
177 {
178 matches = [ { app-id = "^mpv$"; } ];
179 open-on-workspace = "vid";
180 }
181 {
182 matches = [
183 { app-id = "^qemu$"; }
184 { app-id = "^virt-manager$"; }
185 ];
186 open-on-workspace = "mon";
187 }
188 ];
189
190 binds = with config.lib.niri.actions; {
191 "Mod+Slash".action = show-hotkey-overlay;
192
193 "Mod+Return".action = spawn terminal;
194 "Mod+Q".action = close-window;
195 "Mod+D".action = spawn (lib.getExe config.programs.fuzzel.package);
196 "Mod+Shift+D".action = spawn (lib.getExe config.programs.fuzzel.package) "--list-executables-in-path";
197
198 "Mod+H".action = focus-column-left;
199 "Mod+T".action = focus-window-down;
200 "Mod+N".action = focus-window-up;
201 "Mod+S".action = focus-column-right;
202
203 "Mod+Shift+H".action = move-column-left;
204 "Mod+Shift+T".action = move-window-down;
205 "Mod+Shift+N".action = move-window-up;
206 "Mod+Shift+S".action = move-column-right;
207
208 "Mod+Control+H".action = focus-monitor-left;
209 "Mod+Control+T".action = focus-monitor-down;
210 "Mod+Control+N".action = focus-monitor-up;
211 "Mod+Control+S".action = focus-monitor-right;
212
213 "Mod+Shift+Control+H".action = move-workspace-to-monitor-left;
214 "Mod+Shift+Control+T".action = move-workspace-to-monitor-down;
215 "Mod+Shift+Control+N".action = move-workspace-to-monitor-up;
216 "Mod+Shift+Control+S".action = move-workspace-to-monitor-right;
217
218 "Mod+G".action = focus-workspace-down;
219 "Mod+C".action = focus-workspace-up;
220
221 "Mod+Shift+G".action = move-column-to-workspace-down;
222 "Mod+Shift+C".action = move-column-to-workspace-up;
223
224 "Mod+Shift+Control+G".action = move-workspace-down;
225 "Mod+Shift+Control+C".action = move-workspace-up;
226
227 "Mod+M".action = consume-or-expel-window-left;
228 "Mod+W".action = consume-or-expel-window-right;
229
230 "Mod+R".action = switch-preset-column-width;
231 "Mod+Shift+R".action = switch-preset-window-height;
232 "Mod+F".action = center-column;
233 "Mod+Shift+F".action = maximize-column;
234 "Mod+Shift+Ctrl+F".action = fullscreen-window;
235
236 "Mod+B".action = switch-focus-between-floating-and-tiling;
237 "Mod+Shift+B".action = toggle-window-floating;
238
239 "Mod+Left".action = set-column-width "-10%";
240 "Mod+Down".action = set-window-height "-10%";
241 "Mod+Up".action = set-window-height "+10%";
242 "Mod+Right".action = set-column-width "+10%";
243
244 "Mod+Shift+Z" = {
245 action = spawn (lib.getExe niri) "msg" "action" "power-off-monitors";
246 allow-when-locked = true;
247 };
248 "Mod+Shift+L" = {
249 action = spawn loginctl "lock-session";
250 };
251 "Mod+Shift+E".action = quit;
252
253 "XF86MonBrightnessUp" = {
254 action = spawn lightctl "-d" "-e4" "-n1" "up";
255 allow-when-locked = true;
256 };
257 "XF86MonBrightnessDown" = {
258 action = spawn lightctl "-d" "-e4" "-n1" "down";
259 allow-when-locked = true;
260 };
261 "XF86AudioRaiseVolume" = {
262 action = spawn volumectl "-d" "-u" "up";
263 allow-when-locked = true;
264 };
265 "XF86AudioLowerVolume" = {
266 action = spawn volumectl "-d" "-u" "down";
267 allow-when-locked = true;
268 };
269 "XF86AudioMute" = {
270 action = spawn volumectl "-d" "toggle-mute";
271 allow-when-locked = true;
272 };
273 "XF86AudioMicMute" = {
274 action = spawn volumectl "-d" "-m" "toggle-mute";
275 allow-when-locked = true;
276 };
277
278 "Mod+Semicolon".action = spawn dunstctl "close";
279 "Mod+Shift+Semicolon".action = spawn dunstctl "close-all";
280 "Mod+Period".action = spawn dunstctl "context";
281 "Mod+Comma".action = spawn dunstctl "history-pop";
282
283 "Mod+Alt+A".action = focus-or-spawn-action "^com\.saivert\.pwvucontrol$" "pwctl" "pwvucontrol";
284 "Mod+Alt+P".action = focus-or-spawn-action "^org\.keepassxc\.KeePassXC$" "kpxc" "keepassxc";
285 "Mod+Alt+B".action = focus-or-spawn-action "^\.blueman-manager-wrapped$" "bmgr" "blueman-manager";
286 };
287 };
288 };
289}