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,15 +35,14 @@ 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} = {
home-manager.sharedModules = [
{
# https://github.com/YaLTeR/niri/wiki/Configuration:-Key-Bindings
#?? Mod = Super/Win, Alt when nested; Mod5 = AltGr
#?? wev
@ -63,7 +65,7 @@ in {
else ""
} myndows'';
in
listToAttrs (with config.home-manager.users.${config.custom.username}.lib.niri.actions; [
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"))
@ -176,6 +178,7 @@ in {
(key "XF86MonBrightnessUp" null (spawn [swayosd-client "--brightness" "raise"])) # F8
(key "XF86AudioMedia" null (spawn [notify-send "test"])) # F12
]);
};
}
];
};
}

View file

@ -18,7 +18,8 @@ in {
};
config = mkIf cfg.enable {
custom.desktops = mkIf config.custom.full {
custom = {
desktops = mkIf config.custom.full {
niri = {
binds.enable = true;
input.enable = true;
@ -34,6 +35,10 @@ in {
};
};
# Enable rootless Xwayland
services.xwayland-satellite.enable = cfg.xwayland;
};
# https://github.com/YaLTeR/niri
# https://github.com/sodiboo/niri-flake
# https://github.com/sodiboo/niri-flake/blob/main/docs.md
@ -45,14 +50,12 @@ 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.users.${config.custom.username} = {
home-manager.sharedModules = [
{
programs.niri = {
package = config.programs.niri.package;
@ -63,7 +66,7 @@ in {
(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
# TODO: Migrate to window-rules when released
# https://github.com/YaLTeR/niri/pull/871
(plain "window-rule" [
(leaf "match" {title = "^Picture.in.[Pp]icture$";})
@ -77,6 +80,7 @@ in {
#// disable-direct-scanout = [];
};
};
};
}
];
};
}

View file

@ -11,14 +11,33 @@ in {
};
config = mkIf cfg.enable {
home-manager.users.${config.custom.username} = {
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;
@ -28,29 +47,13 @@ in {
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,34 +11,14 @@ in {
};
config = mkIf cfg.enable {
home-manager.users.${config.custom.username} = {
home-manager.sharedModules = [
{
# 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;
# 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-column-widths = [
{proportion = 0.75;}
{proportion = 0.5;}
{proportion = 0.25;}
];
default-column-width = {}; # Window-defined
preset-window-heights = [
{proportion = 0.7;}
{proportion = 0.5;}
{proportion = 0.3;}
{proportion = 1.0;} # Default
];
border = {
enable = true;
width = config.custom.border;
@ -46,13 +26,33 @@ in {
inactive.color = "#00000000";
};
#/// center-focused-column = mkIf config.custom.ultrawide "always";
default-column-width.proportion = 1.0 / 3.0; # 33%
# 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;
focus-ring.enable = false;
gaps = gap;
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;
@ -60,6 +60,7 @@ in {
bottom = gap;
};
};
};
}
];
};
}

View file

@ -5,28 +5,45 @@
...
}:
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} = {
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
#// 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
environment = mapAttrs (name: value: toString value) hm.home.sessionVariables;
hotkey-overlay.skip-at-startup = true;
prefer-no-csd = true;
#!! Not executed in a shell
# https://github.com/YaLTeR/niri/wiki/Configuration:-Key-Bindings#spawn
spawn-at-startup = let
home = config.home-manager.users.${config.custom.username}.home.homeDirectory;
home = hm.home.homeDirectory;
in
[
{command = [_1password "--silent"];} # Launch password manager in background
@ -38,36 +55,13 @@ in {
{command = [wallpaper];}
];
# 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;
# 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;
hide-after-inactive-ms = 1000 * 15; # Milliseconds
hide-when-typing = true;
};
# 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,16 +11,19 @@ in {
};
config = mkIf cfg.enable {
home-manager.users.${config.custom.username} = {
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
workspaces = {
"1" = {};
"2" = {};
"3" = {};
};
#?? niri msg workspaces
# workspaces = {
# "1" = {};
# "2" = {};
# "3" = {};
# };
#?? niri msg windows
window-rules = [
### Defaults
@ -59,7 +62,7 @@ in {
{app-id = "^vivaldi.*$";}
];
open-on-workspace = "2";
#// open-on-workspace = "2";
}
{
@ -84,7 +87,7 @@ in {
{app-id = "^obsidian$";}
];
open-on-workspace = "2";
#// open-on-workspace = "2";
}
{
@ -102,7 +105,8 @@ in {
{app-id = "^steam_app_.+$";}
];
open-on-workspace = "1";
default-column-width = {}; # Window-defined
#// open-on-workspace = "1";
variable-refresh-rate = true;
}
@ -115,7 +119,7 @@ in {
{app-id = "^YouTube Music$";}
];
open-on-workspace = "3";
#// open-on-workspace = "3";
}
{
@ -126,7 +130,7 @@ in {
{app-id = "^ONLYOFFICE Desktop Editors$";}
];
open-on-workspace = "2";
#// open-on-workspace = "2";
}
{
@ -160,12 +164,13 @@ in {
{app-id = "^virt-manager$";}
];
open-on-workspace = "1";
#// open-on-workspace = "1";
}
### Overrides
];
};
};
}
];
};
}