408 lines
13 KiB
Nix
408 lines
13 KiB
Nix
{ self, inputs, ... }:
|
|
|
|
{
|
|
|
|
# niri window manager module declaration
|
|
flake.nixosModules.niri =
|
|
|
|
{ pkgs, lib, ... }:
|
|
|
|
{
|
|
|
|
# for home manager functionality
|
|
imports = [ inputs.home-manager.nixosModules.home-manager ];
|
|
|
|
# for latest niri versions
|
|
nixpkgs.overlays = [ inputs.niri.overlays.niri ];
|
|
|
|
# packages for desktop environment
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
# niri
|
|
xwayland-satellite # xwayland support
|
|
jq # for parsing json
|
|
|
|
# expanded wm controls
|
|
kando # mouse gesture based controls
|
|
|
|
];
|
|
|
|
# enables niri globally
|
|
programs.niri = {
|
|
enable = true;
|
|
# use latest nixpkgs version
|
|
package = with pkgs; niri;
|
|
};
|
|
|
|
# niri personalisation
|
|
home-manager.users.serenity =
|
|
|
|
{ config, ... }:
|
|
|
|
# let binding magic lets me get nice column widths
|
|
let
|
|
|
|
widthDivisions = [
|
|
1.0
|
|
2.0
|
|
3.0
|
|
4.0
|
|
];
|
|
heightDivisions = [
|
|
1.0
|
|
2.0
|
|
3.0
|
|
4.0
|
|
];
|
|
|
|
# black magic, expected output:
|
|
# [ { proportion = 1.0 / 1.0 }
|
|
# { proportion = 1.0 / 2.0 }
|
|
# ...
|
|
# { proportion = 2.0 / 1.0 }
|
|
# { proportion = 2.0 / 3.0 }
|
|
# ...
|
|
# { proportion = 4.0 / 4.0 } ]
|
|
getProportions =
|
|
divisions:
|
|
lib.lists.unique (
|
|
lib.lists.flatten (
|
|
# TODO: make this a callable function
|
|
map (x: map (y: { proportion = x / y; }) divisions) divisions
|
|
)
|
|
);
|
|
|
|
# then get all the unique outputs (removing double ups of 0.5 or others)
|
|
columnWidths = getProportions widthDivisions;
|
|
columnWidthsFiltered = builtins.filter (x: builtins.lessThan x.proportion 1.0) columnWidths; # just get the values that are below 1
|
|
|
|
windowHeights = getProportions heightDivisions;
|
|
windowHeightsFiltered = builtins.filter (x: builtins.lessThan x.proportion 1.0) windowHeights;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
# for niri home manager module
|
|
imports = [ inputs.niri.homeModules.niri ];
|
|
|
|
home.packages = with pkgs; [ ];
|
|
|
|
programs.niri = {
|
|
# enables niri within home manager
|
|
enable = true;
|
|
# use latest nixpkgs version
|
|
package = with pkgs; niri;
|
|
settings = {
|
|
|
|
# xwayland implementation
|
|
xwayland-satellite = {
|
|
enable = true;
|
|
# use niri-stable matching version
|
|
path = lib.getExe pkgs.xwayland-satellite;
|
|
};
|
|
|
|
# environment variables
|
|
environment = {
|
|
# display
|
|
DISPLAY = ":0";
|
|
WLR_RENDERER = "vulkan";
|
|
NIXOS_OZONE_WL = "1";
|
|
SDL_VIDEODRIVER = "wayland";
|
|
# xdg variables
|
|
XDG_CURRENT_DESKTOP = "niri";
|
|
# qt variables
|
|
QT_QPA_PLATFORM = "wayland;xcb";
|
|
QT_QPA_PLATFORMTHEME = "qt5ct";
|
|
QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
|
|
# native wayland firefox
|
|
MOZ_ENABLE_WAYLAND = "1";
|
|
};
|
|
|
|
# display configuration
|
|
outputs."DP-4" = {
|
|
# display scaling
|
|
scale = 1.2;
|
|
# window focus?
|
|
focus-at-startup = true;
|
|
# resolution config
|
|
variable-refresh-rate = true;
|
|
mode = {
|
|
width = 3440;
|
|
height = 1440;
|
|
refresh = 74.924;
|
|
};
|
|
# grid position for this display
|
|
position = {
|
|
x = 0;
|
|
y = 0;
|
|
};
|
|
};
|
|
|
|
# input settings - keybinds further below
|
|
input = {
|
|
# window focus
|
|
focus-follows-mouse = {
|
|
enable = true;
|
|
max-scroll-amount = "0%";
|
|
};
|
|
# keyboard and pointing devices
|
|
keyboard.numlock = true;
|
|
trackpoint = {
|
|
enable = true;
|
|
};
|
|
touchpad = {
|
|
enable = true;
|
|
natural-scroll = true;
|
|
};
|
|
mouse = {
|
|
enable = true;
|
|
natural-scroll = false;
|
|
accel-speed = 1.0;
|
|
accel-profile = "flat";
|
|
};
|
|
};
|
|
|
|
# workspaces
|
|
workspaces."01sys" = {
|
|
name = "System";
|
|
open-on-output = "DP-4";
|
|
};
|
|
|
|
# autostart
|
|
spawn-at-startup = [
|
|
{
|
|
# necessary for xwayland functionality
|
|
argv = [ "xwayland-satellite" ];
|
|
}
|
|
{
|
|
# spawns the desktop shell
|
|
argv = [ "noctalia" ];
|
|
}
|
|
{
|
|
# spawns a terminal running btop
|
|
argv = [
|
|
"kitty"
|
|
"btop"
|
|
];
|
|
}
|
|
{
|
|
# automanages disks
|
|
argv = [ "udiskie" ];
|
|
}
|
|
];
|
|
|
|
# visual settings
|
|
prefer-no-csd = true;
|
|
overview = {
|
|
workspace-shadow.enable = false;
|
|
};
|
|
animations = {
|
|
enable = true;
|
|
slowdown = 1.25;
|
|
};
|
|
layout = {
|
|
|
|
# spawns windows at a specified size
|
|
preset-column-widths =
|
|
builtins.sort
|
|
# sort list for predictable behaviour
|
|
(a: b: builtins.lessThan a.proportion b.proportion)
|
|
columnWidthsFiltered;
|
|
default-column-width.proportion = 1.0 / 3.0;
|
|
|
|
preset-window-heights = builtins.sort (
|
|
a: b: builtins.lessThan a.proportion b.proportion
|
|
) windowHeightsFiltered;
|
|
|
|
# remove backdrop colour
|
|
background-color = "transparent";
|
|
center-focused-column = "never";
|
|
# window|window gaps
|
|
gaps = 8;
|
|
#window|screen edge gaps
|
|
struts = {
|
|
left = 2;
|
|
right = 2;
|
|
top = 2;
|
|
bottom = 4;
|
|
};
|
|
# using focus ring instead of a border
|
|
border.enable = false;
|
|
# highlights the focused window bounds
|
|
focus-ring = {
|
|
enable = true;
|
|
width = 2;
|
|
#focus ring colour
|
|
active.gradient = {
|
|
angle = 45;
|
|
from = "#00cdff";
|
|
to = "#80c8ff";
|
|
};
|
|
};
|
|
# used when increasing window size in steps
|
|
# disabled, using black magic above
|
|
#preset-column-widths = [
|
|
#{ proportion = 0.33; }
|
|
#{ proportion = 0.5; }
|
|
#{ proportion = 0.67; }
|
|
#{ proportion = 1.0; }
|
|
#];
|
|
};
|
|
|
|
layer-rules = [
|
|
|
|
# pushes wallpaper set by noctalia to lowest layer
|
|
{
|
|
matches = [ { namespace = "^noctalia-wallpaper*"; } ];
|
|
place-within-backdrop = true;
|
|
}
|
|
|
|
];
|
|
|
|
window-rules = [
|
|
|
|
# sets corner radius for all windows
|
|
{
|
|
clip-to-geometry = true;
|
|
draw-border-with-background = false;
|
|
geometry-corner-radius =
|
|
let
|
|
radius = 16.0;
|
|
in
|
|
{
|
|
bottom-left = radius;
|
|
bottom-right = radius;
|
|
top-left = radius;
|
|
top-right = radius;
|
|
};
|
|
}
|
|
|
|
# sets sizing and position of floating windows
|
|
{
|
|
matches = [ { is-floating = true; } ];
|
|
opacity = 0.95;
|
|
shadow.enable = true;
|
|
max-width = 1720;
|
|
max-height = 720;
|
|
default-floating-position = {
|
|
relative-to = "top-left";
|
|
x = 1720;
|
|
y = 720;
|
|
};
|
|
}
|
|
|
|
# rules for specific windows
|
|
{
|
|
# kitty opacity
|
|
matches = [ { app-id = "kitty"; } ];
|
|
opacity = 0.95;
|
|
}
|
|
{
|
|
# startup btop spawns on specific workspace
|
|
matches = [
|
|
{
|
|
at-startup = true;
|
|
title = "btop";
|
|
}
|
|
];
|
|
open-on-output = "DP-4";
|
|
open-on-workspace = "System";
|
|
open-maximized = true;
|
|
}
|
|
{
|
|
# calculator spawns floating
|
|
matches = [ { title = "calculator"; } ];
|
|
open-floating = true;
|
|
open-focused = true;
|
|
}
|
|
|
|
];
|
|
|
|
# keybinds
|
|
# https://github.com/niri-wm/niri/wiki/Configuration:-Key-Bindings
|
|
hotkey-overlay = {
|
|
hide-not-bound = true;
|
|
skip-at-startup = true;
|
|
};
|
|
binds = with config.lib.niri.actions; {
|
|
|
|
# debug and utility
|
|
"Mod+Shift+Slash".action = show-hotkey-overlay; # shows help
|
|
"Mod+Shift+Escape" = {
|
|
action = toggle-keyboard-shortcuts-inhibit;
|
|
allow-inhibiting = false; # ensures niri binds are read
|
|
};
|
|
"Mod+Shift+P".action = power-off-monitors; # turn displays off
|
|
"Ctrl+Alt+Delete".action = quit; # log out
|
|
|
|
# task management
|
|
"Mod+Q".action = close-window;
|
|
"Mod+Q".repeat = false;
|
|
"Mod+O".action = toggle-overview;
|
|
"Mod+O".repeat = false;
|
|
#"Mod+Tab".action = spawn "${pkgs.wofi}/bin/wofi";
|
|
#"Mod+Tab".repeat = false; # launcher
|
|
"Mod+Return".action = spawn "${pkgs.kitty}/bin/kitty";
|
|
"Mod+Return".repeat = false; # terminal
|
|
"Mod+Tab".action = spawn { "noctalia-shell" "ipc" "call launcher toggle"; };
|
|
# screen capture
|
|
"Mod+S".action.screenshot = {
|
|
show-pointer = false;
|
|
};
|
|
"Mod+Shift+S".action.screenshot-window = [ ];
|
|
"Mod+Shift+Alt+S".action.screenshot-screen = {
|
|
show-pointer = true;
|
|
};
|
|
|
|
# focus controls
|
|
"Mod+H".action = focus-column-left;
|
|
"Mod+J".action = focus-workspace-down;
|
|
"Mod+K".action = focus-workspace-up;
|
|
"Mod+L".action = focus-column-right;
|
|
"Mod+Left".action = focus-column-left;
|
|
"Mod+Down".action = focus-workspace-down;
|
|
"Mod+Up".action = focus-workspace-up;
|
|
"Mod+Right".action = focus-column-right;
|
|
"Mod+WheelScrollDown".action = focus-workspace-down;
|
|
"Mod+WheelScrollDown".cooldown-ms = 100;
|
|
"Mod+WheelScrollUp".action = focus-workspace-up;
|
|
"Mod+WheelScrollUp".cooldown-ms = 100;
|
|
|
|
# movement controls
|
|
"Mod+Shift+H".action = move-column-left;
|
|
"Mod+Shift+J".action = move-window-down-or-to-workspace-down;
|
|
"Mod+Shift+K".action = move-window-up-or-to-workspace-up;
|
|
"Mod+Shift+L".action = move-column-right;
|
|
"Mod+Shift+Left".action = move-column-left;
|
|
"Mod+Shift+Down".action = move-window-down-or-to-workspace-down;
|
|
"Mod+Shift+Up".action = move-window-up-or-to-workspace-up;
|
|
"Mod+Shift+Right".action = move-column-right;
|
|
"Mod+Shift+WheelScrollDown".action = move-window-down-or-to-workspace-down;
|
|
"Mod+Shift+WheelScrollDown".cooldown-ms = 100;
|
|
"Mod+Shift+WheelScrollUp".action = move-window-up-or-to-workspace-up;
|
|
"Mod+Shift+WheelScrollUp".cooldown-ms = 100;
|
|
|
|
# size controls
|
|
"Mod+Minus".action = switch-preset-column-width-back;
|
|
"Mod+Equal".action = switch-preset-column-width;
|
|
"Mod+Shift+Minus".action = switch-preset-window-height-back;
|
|
"Mod+Shift+Equal".action = switch-preset-window-height;
|
|
"Mod+C".action = center-visible-columns;
|
|
"Mod+F".action = maximize-column;
|
|
"Mod+Shift+F".action = fullscreen-window;
|
|
"Mod+Ctrl+F".action = expand-column-to-available-width;
|
|
"Mod+Space".action = toggle-window-floating;
|
|
"Mod+Shift+Space".action = switch-focus-between-floating-and-tiling;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|