summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/niri/default.nix
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2025-01-14 15:05:32 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2025-01-14 15:05:40 +0100
commitc744867b5adc417748f6ed6fdb17cb6e4c6fc46b (patch)
treecc970543a9e601244f5fab956f52e999b686f4a1 /accounts/gkleen@sif/niri/default.nix
parent21b52a31e1eff5c8142f26e091fde083c21db55f (diff)
downloadnixos-c744867b5adc417748f6ed6fdb17cb6e4c6fc46b.tar
nixos-c744867b5adc417748f6ed6fdb17cb6e4c6fc46b.tar.gz
nixos-c744867b5adc417748f6ed6fdb17cb6e4c6fc46b.tar.bz2
nixos-c744867b5adc417748f6ed6fdb17cb6e4c6fc46b.tar.xz
nixos-c744867b5adc417748f6ed6fdb17cb6e4c6fc46b.zip
...
Diffstat (limited to 'accounts/gkleen@sif/niri/default.nix')
-rw-r--r--accounts/gkleen@sif/niri/default.nix117
1 files changed, 106 insertions, 11 deletions
diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix
index 6a8d10a0..b6165487 100644
--- a/accounts/gkleen@sif/niri/default.nix
+++ b/accounts/gkleen@sif/niri/default.nix
@@ -1,10 +1,35 @@
1{ config, pkgs, lib, ... }: 1{ config, hostConfig, pkgs, lib, ... }:
2let 2let
3 niri = config.programs.niri.package; 3 niri = config.programs.niri.package;
4 terminal = lib.getExe config.programs.kitty.package; 4 terminal = lib.getExe config.programs.kitty.package;
5 lightctl = lib.getExe' config.services.avizo.package "lightctl"; 5 lightctl = lib.getExe' config.services.avizo.package "lightctl";
6 volumectl = lib.getExe' config.services.avizo.package "volumectl"; 6 volumectl = lib.getExe' config.services.avizo.package "volumectl";
7 dunstctl = lib.getExe' config.services.dunst.package "dunstctl"; 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 ];
14 text = ''
15 app_id="$1"
16 shift
17 workspace_name="$1"
18 shift
19
20 niri msg action move-workspace-to-monitor --output "$(niri msg -j workspaces | jq -r '.[] | select(.is_focused) | .output')" "$workspace_name"
21
22 while IFS=$'\n' read -r window_json; do
23 if jq -r '.app_id' <<<"$window_json" | grep -q "$app_id"; then
24 niri msg action focus-window --id "$(jq -r '.id' <<<"$window_json")"
25 exit 0
26 fi
27 done < <(niri msg -j windows | jq -c '.[]')
28
29 exec "$@"
30 '';
31 };
32 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);
8in { 33in {
9 imports = [ 34 imports = [
10 ./waybar.nix 35 ./waybar.nix
@@ -21,7 +46,9 @@ in {
21 Service = { 46 Service = {
22 Type = "notify"; 47 Type = "notify";
23 NotifyAccess = "all"; 48 NotifyAccess = "all";
24 ExecStart = lib.getExe pkgs.xwayland-satellite-unstable; 49 Environment = [ "DISPLAY=:0" ];
50 ExecStart = ''${lib.getExe pkgs.xwayland-satellite-unstable} ''${DISPLAY}'';
51 ExecStartPre = "${systemctl} --user import-environment DISPLAY";
25 StandardOutput = "journal"; 52 StandardOutput = "journal";
26 }; 53 };
27 Install = { 54 Install = {
@@ -29,16 +56,44 @@ in {
29 }; 56 };
30 }; 57 };
31 58
59 services.swayidle = {
60 events = [
61 { event = "after-resume"; command = "${lib.getExe niri} msg action power-on-monitors"; }
62 ];
63 timeouts = [
64 { timeout = 300;
65 command = "${lib.getExe niri} msg action power-off-monitors";
66 }
67 ];
68 };
69
32 programs.niri.settings = { 70 programs.niri.settings = {
33 prefer-no-csd = true; 71 prefer-no-csd = true;
34 screenshot-path = "${config.home.homeDirectory}/screenshots"; 72 screenshot-path = "${config.home.homeDirectory}/screenshots";
35 73
74 hotkey-overlay.skip-at-startup = true;
75
36 input = { 76 input = {
37 keyboard.xkb = { 77 keyboard.xkb = {
38 layout = "us,"; 78 layout = "us,us";
39 variant = "dvp,"; 79 variant = "dvp,";
40 options = "compose:caps,grp:win_space_toggle"; 80 options = "compose:caps,grp:win_space_toggle";
41 }; 81 };
82
83 workspace-auto-back-and-forth = true;
84 # focus-follows-mouse.enable = true;
85 warp-mouse-to-focus = true;
86 };
87
88 outputs = {
89 "Samsung Display Corp. 0x4141 Unknown" = {
90 scale = 1.5;
91 position = { x = 0; y = 0; };
92 };
93 "Ancor Communications Inc ASUS PB287Q 0x0000DD9B" = {
94 scale = 1.5;
95 position = { x = 2560; y = 0; };
96 };
42 }; 97 };
43 98
44 environment = { 99 environment = {
@@ -48,9 +103,40 @@ in {
48 SDL_VIDEODRIVER = "wayland"; 103 SDL_VIDEODRIVER = "wayland";
49 }; 104 };
50 105
106 layout = {
107 gaps = 8;
108 struts = { left = 8; right = 8; top = 0; bottom = 0; };
109 focus-ring = {
110 width = 2;
111 };
112 empty-workspace-above-first = true;
113 };
114
51 cursor.hide-when-typing = true; 115 cursor.hide-when-typing = true;
52 116
117 workspaces = {
118 "01".name = "pwctl";
119 };
120
121 window-rules = [
122 {
123 geometry-corner-radius =
124 let
125 allCorners = r: { bottom-left = r; bottom-right = r; top-left = r; top-right = r; };
126 in allCorners 8.;
127 clip-to-geometry = true;
128 open-focused = false;
129 }
130 {
131 matches = [ { app-id = "^com\.saivert\.pwvucontrol$"; } ];
132 open-on-workspace = "pwctl";
133 open-focused = true;
134 }
135 ];
136
53 binds = with config.lib.niri.actions; { 137 binds = with config.lib.niri.actions; {
138 "Mod+Slash".action = show-hotkey-overlay;
139
54 "Mod+Return".action = spawn terminal; 140 "Mod+Return".action = spawn terminal;
55 "Mod+Q".action = close-window; 141 "Mod+Q".action = close-window;
56 "Mod+D".action = spawn (lib.getExe config.programs.fuzzel.package); 142 "Mod+D".action = spawn (lib.getExe config.programs.fuzzel.package);
@@ -79,17 +165,20 @@ in {
79 "Mod+G".action = focus-workspace-down; 165 "Mod+G".action = focus-workspace-down;
80 "Mod+C".action = focus-workspace-up; 166 "Mod+C".action = focus-workspace-up;
81 167
82 "Mod+Control+G".action = move-column-to-workspace-down; 168 "Mod+Shift+G".action = move-column-to-workspace-down;
83 "Mod+Control+C".action = move-column-to-workspace-up; 169 "Mod+Shift+C".action = move-column-to-workspace-up;
84 170
85 "Mod+Shift+G".action = move-workspace-down; 171 "Mod+Shift+Control+G".action = move-workspace-down;
86 "Mod+Shift+C".action = move-workspace-up; 172 "Mod+Shift+Control+C".action = move-workspace-up;
87 173
88 "Mod+M".action = consume-window-into-column; 174 "Mod+M".action = consume-or-expel-window-left;
89 "Mod+W".action = expel-window-from-column; 175 "Mod+W".action = consume-or-expel-window-right;
90 176
91 "Mod+F".action = maximize-column; 177 "Mod+R".action = switch-preset-column-width;
92 "Mod+Shift+F".action = fullscreen-window; 178 "Mod+Shift+R".action = switch-preset-window-height;
179 "Mod+F".action = center-column;
180 "Mod+Shift+F".action = maximize-column;
181 "Mod+Shift+Ctrl+F".action = fullscreen-window;
93 182
94 "Mod+Space".action = switch-focus-between-floating-and-tiling; 183 "Mod+Space".action = switch-focus-between-floating-and-tiling;
95 "Mod+Shift+Space".action = toggle-window-floating; 184 "Mod+Shift+Space".action = toggle-window-floating;
@@ -103,6 +192,10 @@ in {
103 action = spawn (lib.getExe niri) "msg" "action" "power-off-monitors"; 192 action = spawn (lib.getExe niri) "msg" "action" "power-off-monitors";
104 allow-when-locked = true; 193 allow-when-locked = true;
105 }; 194 };
195 "Mod+Shift+L" = {
196 action = spawn loginctl "lock-session";
197 };
198 "Mod+Shift+E".action = quit;
106 199
107 "XF86MonBrightnessUp" = { 200 "XF86MonBrightnessUp" = {
108 action = spawn lightctl "-d" "-e4" "-n1" "up"; 201 action = spawn lightctl "-d" "-e4" "-n1" "up";
@@ -133,6 +226,8 @@ in {
133 "Mod+Shift+Semicolon".action = spawn dunstctl "close-all"; 226 "Mod+Shift+Semicolon".action = spawn dunstctl "close-all";
134 "Mod+Period".action = spawn dunstctl "context"; 227 "Mod+Period".action = spawn dunstctl "context";
135 "Mod+Comma".action = spawn dunstctl "history-pop"; 228 "Mod+Comma".action = spawn dunstctl "history-pop";
229
230 "Mod+Alt+A".action = focus-or-spawn-action "^com\.saivert\.pwvucontrol$" "pwctl" "pwvucontrol";
136 }; 231 };
137 }; 232 };
138 }; 233 };