1
1
Fork 0

niri: modify config

Signed-off-by: Myned <dev@bjork.tech>
This commit is contained in:
Myned 2024-12-31 12:44:17 -06:00
parent 6d3e618ed5
commit baca73c33e
Signed by: Myned
GPG key ID: C7224454F7881A34
6 changed files with 447 additions and 437 deletions

View file

@ -5,7 +5,10 @@
...
}:
with lib; let
audio = "~/.local/bin/audio";
cfg = config.custom.desktops.niri.binds;
hm = config.home-manager.users.${config.custom.username};
audio = config.home-manager.users.${config.custom.username}.home.file.".local/bin/audio".source;
bash = "${pkgs.bash}/bin/bash";
cat = "${pkgs.coreutils}/bin/cat";
codium = "${config.home-manager.users.${config.custom.username}.programs.vscode.package}/bin/codium";
@ -32,150 +35,150 @@ with lib; let
waydroid = "${pkgs.waydroid}/bin/waydroid";
_1password = "${config.programs._1password-gui.package}/bin/1password";
youtube-music = "${pkgs.youtube-music}/bin/youtube-music";
cfg = config.custom.desktops.niri.binds;
in {
options.custom.desktops.niri.binds = {
enable = mkOption {default = false;};
};
config = mkIf cfg.enable {
home-manager.users.${config.custom.username} = {
# https://github.com/YaLTeR/niri/wiki/Configuration:-Key-Bindings
#?? Mod = Super/Win, Alt when nested; Mod5 = AltGr
#?? wev
programs.niri.settings.binds = let
# Swap modifiers and key for alphabetical sorting
#?? (key "KEY" "MODIFIERS" (ACTION "ARGUMENT"))
key = key: modifiers: action: {
name = "${
if (isString modifiers)
then "${modifiers}+"
else ""
}${key}";
value = {inherit action;};
};
home-manager.sharedModules = [
{
# https://github.com/YaLTeR/niri/wiki/Configuration:-Key-Bindings
#?? Mod = Super/Win, Alt when nested; Mod5 = AltGr
#?? wev
programs.niri.settings.binds = let
# Swap modifiers and key for alphabetical sorting
#?? (key "KEY" "MODIFIERS" (ACTION "ARGUMENT"))
key = key: modifiers: action: {
name = "${
if (isString modifiers)
then "${modifiers}+"
else ""
}${key}";
value = {inherit action;};
};
# Launch VM
vm = ''${remote} --vm --client xfreerdp --username Myned --password "$(${cat} ${config.age.secrets."desktop/vm/myndows.pass".path})" ${
if config.custom.hidpi
then "--scale 140"
else ""
} myndows'';
in
listToAttrs (with config.home-manager.users.${config.custom.username}.lib.niri.actions; [
(key "0" "Mod" (spawn [swayosd-client "--output-volume" "mute-toggle"]))
(key "1" "Ctrl+Alt" (spawn ["lifx" "state" "--brightness" "0.01"]))
(key "1" "Mod" (focus-workspace "1"))
(key "1" "Mod+Alt" (spawn ["lifx" "state" "--kelvin" "1500"]))
(key "1" "Mod+Shift" (move-column-to-workspace "1"))
(key "2" "Ctrl+Alt" (spawn ["lifx" "state" "--brightness" "0.25"]))
(key "2" "Mod" (focus-workspace "2"))
(key "2" "Mod+Alt" (spawn ["lifx" "state" "--kelvin" "2500"]))
(key "2" "Mod+Shift" (move-column-to-workspace "2"))
(key "3" "Ctrl+Alt" (spawn ["lifx" "state" "--brightness" "0.50"]))
(key "3" "Mod" (focus-workspace "3"))
(key "3" "Mod+Alt" (spawn ["lifx" "state" "--kelvin" "3000"]))
(key "3" "Mod+Shift" (move-column-to-workspace "3"))
(key "4" "Ctrl+Alt" (spawn ["lifx" "state" "--brightness" "0.75"]))
(key "4" "Mod" (focus-workspace "4"))
(key "4" "Mod+Alt" (spawn ["lifx" "state" "--kelvin" "4000"]))
(key "4" "Mod+Shift" (move-column-to-workspace "4"))
(key "5" "Ctrl+Alt" (spawn ["lifx" "state" "--brightness" "1.00"]))
(key "5" "Mod" (focus-workspace "5"))
(key "5" "Mod+Alt" (spawn ["lifx" "state" "--kelvin" "5000"]))
(key "5" "Mod+Shift" (move-column-to-workspace "5"))
(key "6" "Mod" (focus-workspace "6"))
(key "6" "Mod+Shift" (move-column-to-workspace "6"))
(key "7" "Mod" (focus-workspace "7"))
(key "7" "Mod+Shift" (move-column-to-workspace "7"))
(key "8" "Mod" (focus-workspace "8"))
(key "8" "Mod+Shift" (move-column-to-workspace "8"))
(key "9" "Mod" (spawn audio))
(key "A" "Ctrl+Alt" (spawn [waydroid "session" "stop"]))
(key "A" "Mod" focus-column-or-monitor-left)
(key "A" "Mod+Ctrl" consume-or-expel-window-left)
(key "A" "Mod+Shift" move-column-left-or-to-monitor-left)
(key "Apostrophe" "Mod" screenshot)
(key "Apostrophe" "Mod+Ctrl+Shift" screenshot-screen)
(key "Apostrophe" "Mod+Shift" screenshot-window)
(key "B" "Ctrl+Alt" (spawn [pkill config.custom.browser.command]))
(key "B" "Mod" (spawn config.custom.browser.command))
(key "Backslash" "Mod" (spawn inhibit))
(key "Backslash" "Mod+Shift" (spawn power))
(key "Bracketleft" "Mod" (switch-layout "prev"))
(key "Bracketright" "Mod" (switch-layout "next"))
(key "C" "Mod" (spawn [walker "--modules" "clipboard"]))
(key "C" "Mod+Ctrl" (spawn [bash "-c" "${rm} ~/.cache/walker/clipboard.gob && ${notify-send} menu 'Clipboard cleared' --urgency low"]))
(key "Delete" "Ctrl+Alt" (spawn [loginctl "terminate-user" config.custom.username]))
(key "Delete" "Mod" (spawn [playerctl] "play-pause"))
(key "Down" "Mod" (spawn [swayosd-client "--brightness" "lower"]))
(key "E" "Ctrl+Alt" (spawn [pkill "codium"]))
(key "E" "Mod" (spawn codium))
(key "Equal" "Mod" (spawn [swayosd-client "--output-volume" "raise"]))
(key "Escape" "Mod" toggle-window-floating)
(key "Escape" "Mod+Alt" (spawn ["lifx" "state" "--color" "red"]))
(key "F" "Mod" (spawn [nautilus "--new-window"]))
(key "G" "Ctrl+Alt" (spawn [pkill "steam"]))
(key "G" "Mod" (spawn steam))
(key "K" "Ctrl+Alt" (spawn [pkill "obsidian"]))
(key "K" "Mod" (spawn obsidian))
(key "L" "Mod" (spawn [bash "-c" "${hyprlock} --immediate & ${niri} msg action power-off-monitors"]))
(key "L" "Mod+Shift" suspend)
(key "Left" "Mod" (spawn [playerctl "previous"]))
(key "M" "Ctrl+Alt" (spawn [pkill "youtube-music"]))
(key "M" "Mod" (spawn youtube-music))
(key "Minus" "Mod" (spawn [swayosd-client "--output-volume" "lower"]))
(key "O" "Mod" (spawn [loupe "/tmp/wallpaper.png"]))
(key "P" "Ctrl+Alt" (spawn [pkill "1password"]))
(key "P" "Mod" (spawn _1password))
(key "Q" "Mod" close-window)
(key "R" "Mod" focus-window-or-workspace-down)
(key "R" "Mod+Shift" move-window-down-or-to-workspace-down)
(key "Return" "Mod" maximize-column)
(key "Return" "Mod+Ctrl" center-column)
(key "Return" "Mod+Shift" fullscreen-window)
(key "Right" "Mod" (spawn [playerctl "next"]))
(key "S" "Mod" focus-column-or-monitor-right)
(key "S" "Mod+Ctrl" consume-or-expel-window-right)
(key "S" "Mod+Shift" move-column-right-or-to-monitor-right)
(key "Semicolon" "Mod" (spawn [hyprpicker "--autocopy"]))
(key "Semicolon" "Mod+Shift" (spawn [hyprpicker "--autocopy --format rgb"]))
(key "Slash" "Mod+Shift" show-hotkey-overlay)
(key "Space" "Ctrl+Alt" (spawn ["lifx" "toggle"]))
(key "Space" "Ctrl+Alt" (spawn ["lifx" "toggle"]))
(key "T" "Ctrl+Alt" (spawn [pkill "kitty"]))
(key "T" "Mod" (spawn kitty))
(key "Tab" "Mod" switch-focus-between-floating-and-tiling)
(key "Up" "Mod" (spawn [swayosd-client "--brightness" "raise"]))
(key "V" "Mod" (spawn virt-manager))
(key "V" "Mod+Ctrl" (spawn vm))
(key "W" "Mod" focus-window-or-workspace-up)
(key "W" "Mod+Shift" move-window-up-or-to-workspace-up)
(key "X" "Mod" switch-preset-column-width)
(key "Z" "Mod" switch-preset-window-height)
# Launch VM
vm = ''${remote} --vm --client xfreerdp --username Myned --password "$(${cat} ${config.age.secrets."desktop/vm/myndows.pass".path})" ${
if config.custom.hidpi
then "--scale 140"
else ""
} myndows'';
in
listToAttrs (with hm.lib.niri.actions; [
(key "0" "Mod" (spawn [swayosd-client "--output-volume" "mute-toggle"]))
(key "1" "Ctrl+Alt" (spawn ["lifx" "state" "--brightness" "0.01"]))
(key "1" "Mod" (focus-workspace "1"))
(key "1" "Mod+Alt" (spawn ["lifx" "state" "--kelvin" "1500"]))
(key "1" "Mod+Shift" (move-column-to-workspace "1"))
(key "2" "Ctrl+Alt" (spawn ["lifx" "state" "--brightness" "0.25"]))
(key "2" "Mod" (focus-workspace "2"))
(key "2" "Mod+Alt" (spawn ["lifx" "state" "--kelvin" "2500"]))
(key "2" "Mod+Shift" (move-column-to-workspace "2"))
(key "3" "Ctrl+Alt" (spawn ["lifx" "state" "--brightness" "0.50"]))
(key "3" "Mod" (focus-workspace "3"))
(key "3" "Mod+Alt" (spawn ["lifx" "state" "--kelvin" "3000"]))
(key "3" "Mod+Shift" (move-column-to-workspace "3"))
(key "4" "Ctrl+Alt" (spawn ["lifx" "state" "--brightness" "0.75"]))
(key "4" "Mod" (focus-workspace "4"))
(key "4" "Mod+Alt" (spawn ["lifx" "state" "--kelvin" "4000"]))
(key "4" "Mod+Shift" (move-column-to-workspace "4"))
(key "5" "Ctrl+Alt" (spawn ["lifx" "state" "--brightness" "1.00"]))
(key "5" "Mod" (focus-workspace "5"))
(key "5" "Mod+Alt" (spawn ["lifx" "state" "--kelvin" "5000"]))
(key "5" "Mod+Shift" (move-column-to-workspace "5"))
(key "6" "Mod" (focus-workspace "6"))
(key "6" "Mod+Shift" (move-column-to-workspace "6"))
(key "7" "Mod" (focus-workspace "7"))
(key "7" "Mod+Shift" (move-column-to-workspace "7"))
(key "8" "Mod" (focus-workspace "8"))
(key "8" "Mod+Shift" (move-column-to-workspace "8"))
(key "9" "Mod" (spawn audio))
(key "A" "Ctrl+Alt" (spawn [waydroid "session" "stop"]))
(key "A" "Mod" focus-column-or-monitor-left)
(key "A" "Mod+Ctrl" consume-or-expel-window-left)
(key "A" "Mod+Shift" move-column-left-or-to-monitor-left)
(key "Apostrophe" "Mod" screenshot)
(key "Apostrophe" "Mod+Ctrl+Shift" screenshot-screen)
(key "Apostrophe" "Mod+Shift" screenshot-window)
(key "B" "Ctrl+Alt" (spawn [pkill config.custom.browser.command]))
(key "B" "Mod" (spawn config.custom.browser.command))
(key "Backslash" "Mod" (spawn inhibit))
(key "Backslash" "Mod+Shift" (spawn power))
(key "Bracketleft" "Mod" (switch-layout "prev"))
(key "Bracketright" "Mod" (switch-layout "next"))
(key "C" "Mod" (spawn [walker "--modules" "clipboard"]))
(key "C" "Mod+Ctrl" (spawn [bash "-c" "${rm} ~/.cache/walker/clipboard.gob && ${notify-send} menu 'Clipboard cleared' --urgency low"]))
(key "Delete" "Ctrl+Alt" (spawn [loginctl "terminate-user" config.custom.username]))
(key "Delete" "Mod" (spawn [playerctl] "play-pause"))
(key "Down" "Mod" (spawn [swayosd-client "--brightness" "lower"]))
(key "E" "Ctrl+Alt" (spawn [pkill "codium"]))
(key "E" "Mod" (spawn codium))
(key "Equal" "Mod" (spawn [swayosd-client "--output-volume" "raise"]))
(key "Escape" "Mod" toggle-window-floating)
(key "Escape" "Mod+Alt" (spawn ["lifx" "state" "--color" "red"]))
(key "F" "Mod" (spawn [nautilus "--new-window"]))
(key "G" "Ctrl+Alt" (spawn [pkill "steam"]))
(key "G" "Mod" (spawn steam))
(key "K" "Ctrl+Alt" (spawn [pkill "obsidian"]))
(key "K" "Mod" (spawn obsidian))
(key "L" "Mod" (spawn [bash "-c" "${hyprlock} --immediate & ${niri} msg action power-off-monitors"]))
(key "L" "Mod+Shift" suspend)
(key "Left" "Mod" (spawn [playerctl "previous"]))
(key "M" "Ctrl+Alt" (spawn [pkill "youtube-music"]))
(key "M" "Mod" (spawn youtube-music))
(key "Minus" "Mod" (spawn [swayosd-client "--output-volume" "lower"]))
(key "O" "Mod" (spawn [loupe "/tmp/wallpaper.png"]))
(key "P" "Ctrl+Alt" (spawn [pkill "1password"]))
(key "P" "Mod" (spawn _1password))
(key "Q" "Mod" close-window)
(key "R" "Mod" focus-window-or-workspace-down)
(key "R" "Mod+Shift" move-window-down-or-to-workspace-down)
(key "Return" "Mod" maximize-column)
(key "Return" "Mod+Ctrl" center-column)
(key "Return" "Mod+Shift" fullscreen-window)
(key "Right" "Mod" (spawn [playerctl "next"]))
(key "S" "Mod" focus-column-or-monitor-right)
(key "S" "Mod+Ctrl" consume-or-expel-window-right)
(key "S" "Mod+Shift" move-column-right-or-to-monitor-right)
(key "Semicolon" "Mod" (spawn [hyprpicker "--autocopy"]))
(key "Semicolon" "Mod+Shift" (spawn [hyprpicker "--autocopy --format rgb"]))
(key "Slash" "Mod+Shift" show-hotkey-overlay)
(key "Space" "Ctrl+Alt" (spawn ["lifx" "toggle"]))
(key "Space" "Ctrl+Alt" (spawn ["lifx" "toggle"]))
(key "T" "Ctrl+Alt" (spawn [pkill "kitty"]))
(key "T" "Mod" (spawn kitty))
(key "Tab" "Mod" switch-focus-between-floating-and-tiling)
(key "Up" "Mod" (spawn [swayosd-client "--brightness" "raise"]))
(key "V" "Mod" (spawn virt-manager))
(key "V" "Mod+Ctrl" (spawn vm))
(key "W" "Mod" focus-window-or-workspace-up)
(key "W" "Mod+Shift" move-window-up-or-to-workspace-up)
(key "X" "Mod" switch-preset-column-width)
(key "Z" "Mod" switch-preset-window-height)
# BUG: Release binds execute with all binds involving that modifier
# https://github.com/YaLTeR/niri/issues/605
# TODO: Uncomment when fixed
#// (key "Shift_L" "Mod" focus-workspace-previous)
# TODO: Use "Super_L" when fixed
(key "Space" "Mod" (spawn walker))
(key "Space" "Mod+Ctrl+Shift" (spawn networkmanager_dmenu))
(key "Space" "Mod+Shift" (spawn [walker "--modules" "search"]))
# BUG: Release binds execute with all binds involving that modifier
# https://github.com/YaLTeR/niri/issues/605
# TODO: Uncomment when fixed
#// (key "Shift_L" "Mod" focus-workspace-previous)
# TODO: Use "Super_L" when fixed
(key "Space" "Mod" (spawn walker))
(key "Space" "Mod+Ctrl+Shift" (spawn networkmanager_dmenu))
(key "Space" "Mod+Shift" (spawn [walker "--modules" "search"]))
# Media keys
# https://github.com/xkbcommon/libxkbcommon/blob/master/include/xkbcommon/xkbcommon-keysyms.h
(key "XF86AudioMute" null (spawn [swayosd-client "--output-volume" "mute-toggle"])) # F1
(key "XF86AudioLowerVolume" null (spawn [swayosd-client "--output-volume" "lower"])) # F2
(key "XF86AudioRaiseVolume" null (spawn [swayosd-client "--output-volume" "raise"])) # F3
(key "XF86AudioPrev" null (spawn [playerctl "previous"])) # F4
(key "XF86AudioPlay" null (spawn [playerctl "play-pause"])) # F5
(key "XF86AudioNext" null (spawn [playerctl "next"])) # F6
(key "XF86MonBrightnessDown" null (spawn [swayosd-client "--brightness" "lower"])) # F7
(key "XF86MonBrightnessUp" null (spawn [swayosd-client "--brightness" "raise"])) # F8
(key "XF86AudioMedia" null (spawn [notify-send "test"])) # F12
]);
};
# Media keys
# https://github.com/xkbcommon/libxkbcommon/blob/master/include/xkbcommon/xkbcommon-keysyms.h
(key "XF86AudioMute" null (spawn [swayosd-client "--output-volume" "mute-toggle"])) # F1
(key "XF86AudioLowerVolume" null (spawn [swayosd-client "--output-volume" "lower"])) # F2
(key "XF86AudioRaiseVolume" null (spawn [swayosd-client "--output-volume" "raise"])) # F3
(key "XF86AudioPrev" null (spawn [playerctl "previous"])) # F4
(key "XF86AudioPlay" null (spawn [playerctl "play-pause"])) # F5
(key "XF86AudioNext" null (spawn [playerctl "next"])) # F6
(key "XF86MonBrightnessDown" null (spawn [swayosd-client "--brightness" "lower"])) # F7
(key "XF86MonBrightnessUp" null (spawn [swayosd-client "--brightness" "raise"])) # F8
(key "XF86AudioMedia" null (spawn [notify-send "test"])) # F12
]);
}
];
};
}

View file

@ -18,20 +18,25 @@ in {
};
config = mkIf cfg.enable {
custom.desktops = mkIf config.custom.full {
niri = {
binds.enable = true;
input.enable = true;
layout.enable = true;
misc.enable = true;
output.enable = true;
rules.enable = true;
custom = {
desktops = mkIf config.custom.full {
niri = {
binds.enable = true;
input.enable = true;
layout.enable = true;
misc.enable = true;
output.enable = true;
rules.enable = true;
};
gnome = {
enable = true;
minimal = true;
};
};
gnome = {
enable = true;
minimal = true;
};
# Enable rootless Xwayland
services.xwayland-satellite.enable = cfg.xwayland;
};
# https://github.com/YaLTeR/niri
@ -45,38 +50,37 @@ in {
nixpkgs.overlays = [inputs.niri-flake.overlays.niri];
#!! Disabled bundled KDE polkit agent
#!! Disable bundled KDE polkit agent by default
# https://github.com/sodiboo/niri-flake?tab=readme-ov-file#additional-notes
systemd.user.services.niri-flake-polkit.enable = cfg.polkit;
# Enable rootless Xwayland
custom.services.xwayland-satellite.enable = cfg.xwayland;
home-manager.sharedModules = [
{
programs.niri = {
package = config.programs.niri.package;
home-manager.users.${config.custom.username} = {
programs.niri = {
package = config.programs.niri.package;
# https://github.com/YaLTeR/niri/wiki/Configuration:-Overview
# HACK: Prepend validated kdl config not currently implemented in settings module for e.g. custom build
# https://github.com/sodiboo/niri-flake/blob/main/settings.nix
config = with inputs.niri-flake.lib;
(internal.settings-module {config = hm;}).options.programs.niri.config.default
# https://github.com/sodiboo/niri-flake/blob/main/default-config.kdl.nix
++ (with kdl; [
# TODO: Migrate to window-rules when released
# https://github.com/YaLTeR/niri/pull/871
(plain "window-rule" [
(leaf "match" {title = "^Picture.in.[Pp]icture$";})
(leaf "open-floating" true)
])
]);
# https://github.com/YaLTeR/niri/wiki/Configuration:-Overview
# HACK: Prepend validated kdl config not currently implemented in settings module for e.g. custom build
# https://github.com/sodiboo/niri-flake/blob/main/settings.nix
config = with inputs.niri-flake.lib;
(internal.settings-module {config = hm;}).options.programs.niri.config.default
# https://github.com/sodiboo/niri-flake/blob/main/default-config.kdl.nix
++ (with kdl; [
# TODO: Migrate to niri.settings when released
# https://github.com/YaLTeR/niri/pull/871
(plain "window-rule" [
(leaf "match" {title = "^Picture.in.[Pp]icture$";})
(leaf "open-floating" true)
])
]);
# https://github.com/YaLTeR/niri/wiki/Configuration:-Debug-Options
# https://github.com/sodiboo/niri-flake/blob/main/docs.md#programsnirisettingsdebug
settings.debug = {
#// disable-direct-scanout = [];
# https://github.com/YaLTeR/niri/wiki/Configuration:-Debug-Options
# https://github.com/sodiboo/niri-flake/blob/main/docs.md#programsnirisettingsdebug
settings.debug = {
#// disable-direct-scanout = [];
};
};
};
};
}
];
};
}

View file

@ -11,46 +11,49 @@ in {
};
config = mkIf cfg.enable {
home-manager.users.${config.custom.username} = {
# https://github.com/YaLTeR/niri/wiki/Configuration:-Input
programs.niri.settings.input = {
keyboard = {
repeat-delay = 300;
repeat-rate = 40;
home-manager.sharedModules = [
{
# https://github.com/YaLTeR/niri/wiki/Configuration:-Input
programs.niri.settings.input = {
# https://github.com/YaLTeR/niri/wiki/Configuration:-Input#general-settings
focus-follows-mouse = {
enable = true;
max-scroll-amount = "100%";
};
power-key-handling.enable = false;
workspace-auto-back-and-forth = true;
# https://github.com/YaLTeR/niri/wiki/Configuration:-Input#keyboard
keyboard = {
repeat-delay = 300;
repeat-rate = 40;
};
# BUG: Applies to trackball device, switch to "flat" when per-device configuration is supported
# https://github.com/YaLTeR/niri/issues/371
# https://github.com/YaLTeR/niri/wiki/Configuration:-Input#pointing-devices
mouse = {
accel-profile = "adaptive";
accel-speed = -0.2;
};
touchpad = {
accel-profile = "adaptive";
accel-speed = 0.3;
click-method = "clickfinger"; # Multi-finger click
dwt = true; # Disable while typing
dwtp = true; # Disable while trackpointing
scroll-factor = 0.4;
};
trackball = {
accel-profile = "adaptive";
accel-speed = 0.5;
middle-emulation = true;
};
};
touchpad = {
accel-profile = "adaptive";
accel-speed = 0.3;
click-method = "clickfinger"; # Multi-finger click
dwt = true; # Disable while typing
dwtp = true; # Disable while trackpointing
scroll-factor = 0.4;
};
# BUG: Applies to trackball device, switch to "flat" when per-device configuration is supported
# https://github.com/YaLTeR/niri/issues/371
mouse = {
accel-profile = "adaptive";
accel-speed = -0.2;
};
trackball = {
accel-profile = "adaptive";
accel-speed = 0.5;
middle-emulation = true;
};
power-key-handling.enable = false;
focus-follows-mouse = {
enable = true;
max-scroll-amount = "70%";
};
workspace-auto-back-and-forth = true;
};
};
}
];
};
}

View file

@ -11,55 +11,56 @@ in {
};
config = mkIf cfg.enable {
home-manager.users.${config.custom.username} = {
# https://github.com/YaLTeR/niri/wiki/Configuration:-Layout
programs.niri.settings.layout = let
gap = config.custom.gap / 2;
in {
gaps = gap;
#// center-focused-column = mkIf config.custom.ultrawide "always";
always-center-single-column = true;
home-manager.sharedModules = [
{
# https://github.com/YaLTeR/niri/wiki/Configuration:-Layout
programs.niri.settings.layout = let
gap = config.custom.gap / 2;
in {
always-center-single-column = true;
# TODO: Uncomment after next release > v1.10.1
# https://github.com/YaLTeR/niri/wiki/Configuration:-Layout#empty-workspace-above-first
#// empty-workspace-above-first = true;
border = {
enable = true;
width = config.custom.border;
active.color = "#d33682";
inactive.color = "#00000000";
};
preset-column-widths = [
{proportion = 0.75;}
{proportion = 0.5;}
{proportion = 0.25;}
];
#/// center-focused-column = mkIf config.custom.ultrawide "always";
default-column-width.proportion = 1.0 / 3.0; # 33%
default-column-width = {}; # Window-defined
# TODO: Uncomment after next release > v1.10.1
# https://github.com/YaLTeR/niri/wiki/Configuration:-Layout#empty-workspace-above-first
#// empty-workspace-above-first = true;
preset-window-heights = [
{proportion = 0.7;}
{proportion = 0.5;}
{proportion = 0.3;}
{proportion = 1.0;} # Default
];
focus-ring.enable = false;
gaps = gap;
border = {
enable = true;
width = config.custom.border;
active.color = "#d33682";
inactive.color = "#00000000";
insert-hint = {
enable = true;
display.color = "#d3368280";
};
preset-column-widths = [
{proportion = 1.0 / 3.0;} # 33%, default
{proportion = 2.0 / 3.0;} # 66%
{proportion = 3.0 / 3.0;} # 100%
];
preset-window-heights = [
{proportion = 2.0 / 3.0;} # 66%
{proportion = 1.0 / 3.0;} # 33%
{proportion = 3.0 / 3.0;} # 100%, default
];
struts = {
left = gap;
right = gap;
top = gap;
bottom = gap;
};
};
focus-ring.enable = false;
insert-hint = {
enable = true;
display.color = "#d3368280";
};
struts = {
left = gap;
right = gap;
top = gap;
bottom = gap;
};
};
};
}
];
};
}

View file

@ -5,69 +5,63 @@
...
}:
with lib; let
cfg = config.custom.desktops.niri.misc;
hm = config.home-manager.users.${config.custom.username};
_1password = "${config.programs._1password-gui.package}/bin/1password";
audio = config.home-manager.users.${config.custom.username}.home.file.".local/bin/audio".source;
niri = "${config.programs.niri.package}/bin/niri";
rm = "${pkgs.coreutils}/bin/rm";
sway-audio-idle-inhibit = "${pkgs.sway-audio-idle-inhibit}/bin/sway-audio-idle-inhibit";
wallpaper = "${config.home-manager.users.${config.custom.username}.home.file.".local/bin/wallpaper".source}";
cfg = config.custom.desktops.niri.misc;
in {
options.custom.desktops.niri.misc = {
enable = mkOption {default = false;};
};
config = mkIf cfg.enable {
home-manager.users.${config.custom.username} = {
programs.niri.settings = {
# https://github.com/YaLTeR/niri/wiki/Configuration:-Miscellaneous
home-manager.sharedModules = [
{
programs.niri.settings = {
# https://github.com/YaLTeR/niri/wiki/Configuration:-Miscellaneous
cursor = with hm.gtk.cursorTheme; {
# Inherit home-manager GTK settings
inherit size;
theme = name;
# https://github.com/YaLTeR/niri/wiki/Configuration:-Miscellaneous#spawn-at-startup
# https://github.com/YaLTeR/niri/wiki/Configuration:-Key-Bindings#actions
spawn-at-startup = let
home = config.home-manager.users.${config.custom.username}.home.homeDirectory;
in
[
{command = [_1password "--silent"];} # Launch password manager in background
{command = [audio "--init"];} # Enforce audio profile state
{command = [rm "${home}/.cache/walker/clipboard.gob"];} # Clear clipboard history
{command = [sway-audio-idle-inhibit];} # Inhibit while audio is playing
]
++ optionals config.custom.wallpaper [
{command = [wallpaper];}
];
#// hide-after-inactive-ms = 1000 * 15; # Milliseconds
hide-when-typing = true;
};
# HACK: Inherit home-manager environment variables in lieu of upstream fix
# https://github.com/nix-community/home-manager/issues/2659
# https://github.com/YaLTeR/niri/wiki/Configuration:-Miscellaneous#environment
environment =
mapAttrs (name: value: toString value)
config.home-manager.users.${config.custom.username}.home.sessionVariables;
# HACK: Inherit home-manager environment variables in lieu of upstream fix
# https://github.com/nix-community/home-manager/issues/2659
environment = mapAttrs (name: value: toString value) hm.home.sessionVariables;
# https://github.com/YaLTeR/niri/wiki/Configuration:-Miscellaneous#cursor
cursor = with config.home-manager.users.${config.custom.username}.gtk.cursorTheme; {
# Inherit home-manager GTK settings
inherit size;
theme = name;
hotkey-overlay.skip-at-startup = true;
prefer-no-csd = true;
hide-after-inactive-ms = 1000 * 15; # Milliseconds
hide-when-typing = true;
#!! Not executed in a shell
# https://github.com/YaLTeR/niri/wiki/Configuration:-Key-Bindings#spawn
spawn-at-startup = let
home = hm.home.homeDirectory;
in
[
{command = [_1password "--silent"];} # Launch password manager in background
{command = [audio "--init"];} # Enforce audio profile state
{command = [rm "${home}/.cache/walker/clipboard.gob"];} # Clear clipboard history
{command = [sway-audio-idle-inhibit];} # Inhibit while audio is playing
]
++ optionals config.custom.wallpaper [
{command = [wallpaper];}
];
switch-events = {
# Turn display off while inhibiting suspend
lid-close.action.spawn = [niri "msg" "action" "power-off-monitors"];
lid-open.action.spawn = [niri "msg" "action" "power-on-monitors"];
};
};
# https://github.com/YaLTeR/niri/wiki/Configuration:-Miscellaneous#hotkey-overlay
hotkey-overlay.skip-at-startup = true;
# https://github.com/YaLTeR/niri/wiki/Configuration:-Miscellaneous#prefer-no-csd
prefer-no-csd = true;
# https://github.com/YaLTeR/niri/wiki/Configuration:-Switch-Events
switch-events = {
# Turn display off while inhibiting suspend
lid-close.action.spawn = [niri "msg" "action" "power-off-monitors"];
lid-open.action.spawn = [niri "msg" "action" "power-on-monitors"];
};
};
};
}
];
};
}

View file

@ -11,161 +11,166 @@ in {
};
config = mkIf cfg.enable {
home-manager.users.${config.custom.username} = {
# https://github.com/YaLTeR/niri/wiki/Configuration:-Window-Rules
programs.niri.settings = {
# HACK: Name workspaces after index to use open-on-workspace rule
workspaces = {
"1" = {};
"2" = {};
"3" = {};
};
home-manager.sharedModules = [
{
# https://github.com/YaLTeR/niri/wiki/Configuration:-Window-Rules
programs.niri.settings = {
# HACK: Name workspaces after index to use open-on-workspace rule
#?? niri msg workspaces
# workspaces = {
# "1" = {};
# "2" = {};
# "3" = {};
# };
window-rules = [
### Defaults
#?? niri msg windows
window-rules = [
### Defaults
{
# Global
geometry-corner-radius = let
radius = config.custom.rounding + 0.0; # Convert to float
in {
top-left = radius;
top-right = radius;
bottom-right = radius;
bottom-left = radius;
};
{
# Global
geometry-corner-radius = let
radius = config.custom.rounding + 0.0; # Convert to float
in {
top-left = radius;
top-right = radius;
bottom-right = radius;
bottom-left = radius;
};
clip-to-geometry = true;
}
clip-to-geometry = true;
}
{
# Startup
#?? <= 60 secs after niri launches
matches = [{at-startup = true;}];
}
{
# Startup
#?? <= 60 secs after niri launches
matches = [{at-startup = true;}];
}
{
# Android
matches = [{app-id = "^[Ww]aydroid.*$";}];
}
{
# Android
matches = [{app-id = "^[Ww]aydroid.*$";}];
}
{
# Browsers
matches = [
{app-id = "^brave-browser$";}
{app-id = "^chromium-browser$";}
{app-id = "^firefox.*$";}
{app-id = "^google-chrome$";}
{app-id = "^vivaldi.*$";}
];
{
# Browsers
matches = [
{app-id = "^brave-browser$";}
{app-id = "^chromium-browser$";}
{app-id = "^firefox.*$";}
{app-id = "^google-chrome$";}
{app-id = "^vivaldi.*$";}
];
open-on-workspace = "2";
}
#// open-on-workspace = "2";
}
{
# Chats
matches = [
{app-id = "^cinny$";}
{app-id = "^discord$";}
{app-id = "^Element$";}
{app-id = "^org\.telegram\.desktop$";}
];
}
{
# Chats
matches = [
{app-id = "^cinny$";}
{app-id = "^discord$";}
{app-id = "^Element$";}
{app-id = "^org\.telegram\.desktop$";}
];
}
{
# Dropdown terminal
matches = [{app-id = "^dropdown$";}];
}
{
# Dropdown terminal
matches = [{app-id = "^dropdown$";}];
}
{
# Editors
matches = [
{app-id = "^codium$";}
{app-id = "^obsidian$";}
];
{
# Editors
matches = [
{app-id = "^codium$";}
{app-id = "^obsidian$";}
];
open-on-workspace = "2";
}
#// open-on-workspace = "2";
}
{
# Files
matches = [{app-id = "^org\.gnome\.Nautilus$";}];
}
{
# Files
matches = [{app-id = "^org\.gnome\.Nautilus$";}];
}
{
# Games
matches = [
{app-id = "^.*\.(exe|x86_64)$";}
{
# Games
matches = [
{app-id = "^.*\.(exe|x86_64)$";}
{app-id = "^love$";} # vrrtest
{app-id = "^moe\.launcher\..+$";} # Anime Game Launcher
{app-id = "^net\.retrodeck\.retrodeck$";}
{app-id = "^steam_app_.+$";}
];
{app-id = "^net\.retrodeck\.retrodeck$";}
{app-id = "^steam_app_.+$";}
];
open-on-workspace = "1";
variable-refresh-rate = true;
}
default-column-width = {}; # Window-defined
#// open-on-workspace = "1";
variable-refresh-rate = true;
}
{
# Media
matches = [
{app-id = "^org\.gnome\.Loupe$";}
{app-id = "^Spotify$";}
{app-id = "^totem$";}
{app-id = "^YouTube Music$";}
];
{
# Media
matches = [
{app-id = "^org\.gnome\.Loupe$";}
{app-id = "^Spotify$";}
{app-id = "^totem$";}
{app-id = "^YouTube Music$";}
];
open-on-workspace = "3";
}
#// open-on-workspace = "3";
}
{
# Office
matches = [
{app-id = "^draw\.io$";}
{app-id = "^libreoffice$";}
{app-id = "^ONLYOFFICE Desktop Editors$";}
];
{
# Office
matches = [
{app-id = "^draw\.io$";}
{app-id = "^libreoffice$";}
{app-id = "^ONLYOFFICE Desktop Editors$";}
];
open-on-workspace = "2";
}
#// open-on-workspace = "2";
}
{
# PiP
matches = [{title = "^Picture.in.[Pp]icture$";}];
}
{
# PiP
matches = [{title = "^Picture.in.[Pp]icture$";}];
}
{
# Terminals
matches = [
{app-id = "^foot$";}
{app-id = "^kitty$";}
{app-id = "^org\.wezfurlong\.wezterm$";}
];
}
{
# Terminals
matches = [
{app-id = "^foot$";}
{app-id = "^kitty$";}
{app-id = "^org\.wezfurlong\.wezterm$";}
];
}
{
# Vaults
matches = [
{app-id = "^1Password$";}
{app-id = "^Bitwarden$";}
];
}
{
# Vaults
matches = [
{app-id = "^1Password$";}
{app-id = "^Bitwarden$";}
];
}
{
# Virtual machines
matches = [
{app-id = "^(sdl-|wl|x)freerdp$";}
{app-id = "^looking-glass-client$";}
{app-id = "^org\.remmina\.Remmina$";}
{app-id = "^virt-manager$";}
];
{
# Virtual machines
matches = [
{app-id = "^(sdl-|wl|x)freerdp$";}
{app-id = "^looking-glass-client$";}
{app-id = "^org\.remmina\.Remmina$";}
{app-id = "^virt-manager$";}
];
open-on-workspace = "1";
}
#// open-on-workspace = "1";
}
### Overrides
];
};
};
### Overrides
];
};
}
];
};
}