From 11b9d5239bbce7e1ea5ef2cd4bb3073d6abbc0dc Mon Sep 17 00:00:00 2001 From: Miran Bastaja Date: Mon, 30 Jun 2025 15:04:46 +0200 Subject: init: niri config --- share/home/dev-stuff.nix | 1 + share/home/niri.nix | 233 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 232 insertions(+), 2 deletions(-) (limited to 'share/home') diff --git a/share/home/dev-stuff.nix b/share/home/dev-stuff.nix index 259dfdd..f8a90fd 100644 --- a/share/home/dev-stuff.nix +++ b/share/home/dev-stuff.nix @@ -66,6 +66,7 @@ in gleam erlang sqlx-cli + cachix # TUI/GUI zed-editor diff --git a/share/home/niri.nix b/share/home/niri.nix index 52d2ed4..eb6cce9 100644 --- a/share/home/niri.nix +++ b/share/home/niri.nix @@ -1,6 +1,235 @@ -{ pkgs, ... }: { - home.packages = with pkgs; [ xwayland-satellite ]; + pkgs, + config, + inputs, + ... +}: +{ + imports = [ + inputs.niri-flake.homeModules.niri + ]; programs.waybar.enable = true; programs.tofi.enable = true; + programs.kitty.enable = true; + + programs.niri.settings = { + input = { + keyboard.xkb = { + layout = "us,hr"; + options = "grp:win_space_toggle"; + }; + touchpad = { + enable = true; + tap = true; + natural-scroll = true; + }; + mouse = { + enable = true; + accel-profile = "flat"; + }; + }; + + outputs."eDP-1" = { + enable = true; + mode = { + width = 1920; + height = 1080; + }; + scale = 2; + # transform = "normal"; + # position = { + # # From the default config, no idea why + # x = 1280; + # y = 0; + # }; + }; + + layout = { + gaps = 16; + center-focused-column = "never"; + # You can customize the widths that "switch-preset-column-width" (Mod+R) toggles between. + preset-column-widths = [ + { proportion = 1. / 3.; } + { proportion = 1. / 2.; } + { proportion = 2. / 3.; } + ]; + default-column-width.proportion = 1. / 2.; + focus-ring = { + width = 4; + active.color = "#7fc8ff"; + inactive.color = "#505050"; + }; + }; + + spawn-at-startup = [ + { command = [ "${pkgs.xwayland-satellite}/bin/xwayland-satellite" ]; } + ]; + + environment = { + QT_QPA_PLATFORM = "wayland"; + DISPLAY = ":0"; # for X11 to recognize xwayland-satellite correctly + }; + + screenshot-path = null; # clipboard only + + window-rules = [ + # Open the Firefox picture-in-picture player as floating by default. + { + matches = [ { title = "^Picture-in-Picture$"; } ]; + open-floating = true; + } + + # Work around WezTerm's initial configure bug by setting an empty default-column-width. + { + matches = [ { app-id = ''^org\.wezfurlong\.wezterm$''; } ]; + default-column-width = null; + } + + { + matches = [ + { app-id = ''^org\.keepassxc\.KeePassXC$''; } + { app-id = ''^org\.gnome\.World\.Secrets$''; } + { app-id = ''^Bitwarden$''; } + ]; + block-out-from = "screen-capture"; + } + ]; + + binds = with config.lib.niri.actions; { + # Shows a list of important hotkeys + "Mod+Shift+Slash".action = show-hotkey-overlay; + + "Mod+Shift+Return".action = spawn "kitty"; + "Mod+P".action = spawn "tofi-drun"; + "Mod+Shift+P".action = spawn "tofi-run"; + + # Audio stuff + "XF86AudioRaiseVolume" = { + allow-when-locked = true; + action = spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.1+"; + }; + "XF86AudioLowerVolume" = { + allow-when-locked = true; + action = spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.1-"; + }; + "XF86AudioMute" = { + allow-when-locked = true; + action = spawn "wpctl" "set-mute" "@DEFAULT_AUDIO_SINK@" "toggle"; + }; + "XF86AudioMicMute" = { + allow-when-locked = true; + action = spawn "wpctl" "set-mute" "@DEFAULT_AUDIO_SOURCE@" "toggle"; + }; + + # general window management + "Mod+Shift+C".action = close-window; + "Mod+Left".action = focus-column-left; + "Mod+Down".action = focus-window-down; + "Mod+Up".action = focus-window-up; + "Mod+Right".action = focus-column-right; + "Mod+H".action = focus-column-left; + "Mod+J".action = focus-window-down; + "Mod+K".action = focus-window-up; + "Mod+L".action = focus-column-right; + + "Mod+Shift+Left".action = move-column-left; + "Mod+Shift+Down".action = move-window-down; + "Mod+Shift+Up".action = move-window-up; + "Mod+Shift+Right".action = move-column-right; + "Mod+Shift+H".action = move-column-left; + "Mod+Shift+J".action = move-window-down; + "Mod+Shift+K".action = move-window-up; + "Mod+Shift+L".action = move-column-right; + + "Mod+Home".action = focus-column-first; + "Mod+End".action = focus-column-last; + "Mod+Shift+Home".action = move-column-to-first; + "Mod+Shift+End".action = move-column-to-last; + + "Mod+Page_Down".action = focus-workspace-down; + "Mod+Page_Up".action = focus-workspace-up; + "Mod+U".action = focus-workspace-down; + "Mod+I".action = focus-workspace-up; + "Mod+Shift+U".action = move-column-to-workspace-down; + "Mod+Shift+I".action = move-column-to-workspace-up; + + "Mod+Shift+Page_Down".action = move-workspace-down; + "Mod+Shift+Page_Up".action = move-workspace-up; + + "Mod+WheelScrollDown".action = focus-workspace-down; + "Mod+WheelScrollUp".action = focus-workspace-up; + "Mod+Ctrl+WheelScrollDown".action = move-column-to-workspace-down; + "Mod+Ctrl+WheelScrollUp".action = move-column-to-workspace-up; + + "Mod+WheelScrollRight".action = focus-column-right; + "Mod+WheelScrollLeft".action = focus-column-left; + "Mod+Ctrl+WheelScrollRight".action = move-column-right; + "Mod+Ctrl+WheelScrollLeft".action = move-column-left; + + "Mod+Shift+WheelScrollDown".action = focus-column-right; + "Mod+Shift+WheelScrollUp".action = focus-column-left; + "Mod+Ctrl+Shift+WheelScrollDown".action = move-column-right; + "Mod+Ctrl+Shift+WheelScrollUp".action = move-column-left; + + "Mod+1".action = focus-workspace 1; + "Mod+2".action = focus-workspace 2; + "Mod+3".action = focus-workspace 3; + "Mod+4".action = focus-workspace 4; + "Mod+5".action = focus-workspace 5; + "Mod+6".action = focus-workspace 6; + "Mod+7".action = focus-workspace 7; + "Mod+8".action = focus-workspace 8; + "Mod+9".action = focus-workspace 9; + "Mod+Shift+1".action.move-column-to-workspace = 1; + "Mod+Shift+2".action.move-column-to-workspace = 2; + "Mod+Shift+3".action.move-column-to-workspace = 3; + "Mod+Shift+4".action.move-column-to-workspace = 4; + "Mod+Shift+5".action.move-column-to-workspace = 5; + "Mod+Shift+6".action.move-column-to-workspace = 6; + "Mod+Shift+7".action.move-column-to-workspace = 7; + "Mod+Shift+8".action.move-column-to-workspace = 8; + "Mod+Shift+9".action.move-column-to-workspace = 9; + + "Mod+BracketLeft".action = consume-or-expel-window-left; + "Mod+BracketRight".action = consume-or-expel-window-right; + + # Consume one window from the right to the bottom of the focused column. + "Mod+Comma".action = consume-window-into-column; + # Expel the bottom window from the focused column to the right. + "Mod+Period".action = expel-window-from-column; + + "Mod+R".action = switch-preset-column-width; + "Mod+Shift+R".action = switch-preset-window-height; + "Mod+Ctrl+R".action = reset-window-height; + "Mod+F".action = maximize-column; + "Mod+Shift+F".action = fullscreen-window; + + # Expand the focused column to space not taken up by other fully visible columns. + # Makes the column "fill the rest of the space". + "Mod+Ctrl+F".action = expand-column-to-available-width; + + "Mod+C".action = center-column; + + "Mod+Minus".action = set-column-width "-10%"; + "Mod+Equal".action = set-column-width "+10%"; + "Mod+Shift+Minus".action = set-window-height "-10%"; + "Mod+Shift+Equal".action = set-window-height "+10%"; + + "Mod+V".action = toggle-window-floating; + "Mod+Shift+V".action = switch-focus-between-floating-and-tiling; + + "Mod+W".action = toggle-column-tabbed-display; + + "Print".action = screenshot; + "Alt+Print".action = screenshot-window; + + "Mod+Escape" = { + allow-inhibiting = false; + action = toggle-keyboard-shortcuts-inhibit; + }; + + "Mod+Shift+E".action = quit; + "Ctrl+Alt+Delete".action = quit; + }; + }; } -- cgit v1.3.1