From 791bc419b6dac7c70951981ef6b34cdf85828470 Mon Sep 17 00:00:00 2001 From: adikro Date: Sat, 20 Dec 2025 03:14:45 +0100 Subject: absolutely massive rewrite, made (almost) everything modular with changes to come --- hm/env/niri/binds.nix | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++ hm/env/niri/niri.nix | 94 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 hm/env/niri/binds.nix create mode 100644 hm/env/niri/niri.nix (limited to 'hm/env/niri') diff --git a/hm/env/niri/binds.nix b/hm/env/niri/binds.nix new file mode 100644 index 0000000..cb0feca --- /dev/null +++ b/hm/env/niri/binds.nix @@ -0,0 +1,98 @@ +{ config, lib, pkgs, ... }: + +with config.lib.niri.actions; +let + playerctl = spawn "${pkgs.playerctl}/bin/playerctl"; +in +{ + "Mod+O" = { + action = toggle-overview; + repeat = false; + }; + "Mod+Slash".action = show-hotkey-overlay; + + # Audio + XF86AudioRaiseVolume.action = playerctl "volume" "0.02+"; + XF86AudioLowerVolume.action = playerctl "volume" "0.02-"; + XF86AudioMute.action = spawn "wpctl" "set-mute" "@DEFAULT_AUDIO_SINK@" "toggle"; + XF86AudioMicMute.action = spawn "wpctl" "set-mute" "@DEFAULT_AUDIO_SOURCE@" "toggle"; + + # Media keys + XF86AudioPlay.action = playerctl "play-pause"; + XF86AudioPrev.action = playerctl "previous"; + XF86AudioNext.action = playerctl "next"; + + # Column sizing + "Mod+Minus".action = set-column-width "-10%"; + "Mod+Equal".action = set-column-width "+10%"; + + # Finer height adjustments when in column with other windows. + "Mod+Shift+Minus".action = set-window-height "-10%"; + "Mod+Shift+Equal".action = set-window-height "+10%"; + + # Misc + "Mod+Shift+V".action = toggle-window-floating; + "Mod+Shift+P".action = power-off-monitors; + "Mod+W".action = toggle-column-tabbed-display; + + "Mod+S".action = spawn "sh" "-c" + '' + filename="/media/pics/ss/$(date +%Y-%m-%d_%H-%M-%S).png" + grim -g "$(slurp)" - | tee "$filename" | wl-copy + ''; + + "Mod+Shift+S".action = spawn "sh" "-c" + '' + filename="/media/pics/ss/$(date +%Y-%m-%d_%H-%M-%S).png" + grim -g "$(slurp)" "$filename" + + edited="/media/pics/ss/$(date +%Y-%m-%d_%H-%M-%S)-edited.png" + satty --filename "$filename" --output-filename "$edited" + ''; + + "Mod+Shift+D".action = spawn "sh" "-c" + '' + cliphist list | fuzzel --dmenu | cliphist decode | wl-copy + ''; + + # --- System / General --- + "Mod+Return".action = spawn "foot"; + "Mod+D".action = spawn "fuzzel"; + "Mod+C".action = spawn "qalculate-gtk"; + "Mod+BracketLeft".action = consume-or-expel-window-left; + "Mod+BracketRight".action = consume-or-expel-window-right; + + "Mod+R".action = switch-preset-column-width; + "Mod+Shift+R".action = reset-window-height; + "Mod+F".action = maximize-column; + "Mod+Shift+F".action = fullscreen-window; + + "Mod+Comma".action = consume-window-into-column; + "Mod+Period".action = expel-window-from-column; + + "Mod+Shift+E".action = quit; + + # --- Window Navigation (Focus) --- + "Mod+H".action = focus-column-left; + "Mod+L".action = focus-column-right; + "Mod+J".action = focus-workspace-down; + "Mod+K".action = focus-workspace-up; + + # --- Window Management (Move) --- + "Mod+Shift+H".action = move-column-left; + "Mod+Shift+L".action = move-column-right; + "Mod+Shift+J".action = move-window-down-or-to-workspace-down; + "Mod+Shift+K".action = move-window-up-or-to-workspace-up; + + # --- Window State --- + "Mod+Shift+Q".action = close-window; + +} // ( + # --- Generated Workspace Binds (1-9) --- + builtins.listToAttrs (builtins.concatMap (i: let + strI = toString i; + in [ + { name = "Mod+${strI}"; value.action = focus-workspace i; } + { name = "Mod+Shift+${strI}"; value.action.move-column-to-workspace = [ i ]; } + ]) (lib.range 1 9)) +) diff --git a/hm/env/niri/niri.nix b/hm/env/niri/niri.nix new file mode 100644 index 0000000..fddfcac --- /dev/null +++ b/hm/env/niri/niri.nix @@ -0,0 +1,94 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.szpont.hm.env.niri; +in +{ + options.szpont.hm.env.niri.enable = lib.mkEnableOption "niri hm"; + config = lib.mkIf cfg.enable { + + szpont.hm.soft = { + awww.enable = true; + fuzzel.enable = true; + satty.enable = true; + swayidle.enable = true; + swaylock.enable = true; + }; + + programs.niri.settings = { + binds = import ./binds.nix { inherit config lib pkgs; }; + + prefer-no-csd = true; + hotkey-overlay.skip-at-startup = true; + input = { + mouse = { + accel-profile = "flat"; + accel-speed = -0.6; + middle-emulation = true; + scroll-factor = 1.5; + }; + focus-follows-mouse = { + enable = true; + max-scroll-amount = "10%"; + }; + mod-key = "Alt"; + keyboard = { + xkb.layout = "pl"; + repeat-delay = 400; + repeat-rate = 60; + }; + power-key-handling.enable = false; + }; + outputs = { + "DP-1" = { + focus-at-startup = true; + # backdrop-color = ""; + variable-refresh-rate = "on-demand"; + mode = { + width = 2560; + height = 1440; + refresh = 239.998; + }; + }; + }; + cursor = { + hide-when-typing = true; + size = 8; + # theme = ""; + }; + layout = { + border = { + width = 2; + # active = ; + }; + focus-ring = { + width = 2; + # active = ; + }; + preset-column-widths = [ + { proportion = 1. / 3.; } + { proportion = 1. / 2.; } + { proportion = 2. / 3.; } + ]; + preset-window-heights = [ + { proportion = 1. / 3.; } + { proportion = 1. / 2.; } + { proportion = 2. / 3.; } + ]; + default-column-width.proportion = 0.5; + tab-indicator = { + gaps-between-tabs = 3; + position = "top"; + }; + }; + spawn-at-startup = [ + { command = [ "${lib.getExe pkgs.xwayland-satellite}" ]; } + { command = [ "awww-daemon" ]; } + ]; + }; + home.packages = with pkgs; [ + qalculate-gtk + grim + slurp + ]; + }; +} -- cgit v1.3