modules/home/desktop/niri/default.nix: use functions to generate content

Signed-off-by: unexplrd <unexplrd@linerds.us>
This commit is contained in:
2025-03-30 20:44:42 +03:00
parent 51f669c7b2
commit 5b35a48358

View File

@ -282,10 +282,78 @@ in {
niri = { niri = {
target = "niri/config.kdl"; target = "niri/config.kdl";
text = let text = let
arrows = {
left = "Left";
down = "Down";
up = "Up";
right = "Right";
};
homerow-arrows = {
left = "n"; left = "n";
down = "e"; down = "e";
up = "i"; up = "i";
right = "o"; right = "o";
};
letters = {
first = "Q";
second = "W";
third = "F";
fourth = "P";
fifth = "B";
sixth = "J";
seventh = "L";
eighth = "U";
ninth = "Y";
};
numbers = {
first = "1";
second = "2";
third = "3";
fourth = "4";
fifth = "5";
sixth = "6";
seventh = "7";
eighth = "8";
ninth = "9";
};
genArrowNavigation = keys: ''
Mod+${keys.left} { focus-column-left; }
Mod+${keys.down} { focus-window-or-workspace-down; }
Mod+${keys.up} { focus-window-or-workspace-up; }
Mod+${keys.right} { focus-column-right; }
Mod+Ctrl+${keys.left} { move-column-left; }
Mod+Ctrl+${keys.down} { move-window-down-or-to-workspace-down; }
Mod+Ctrl+${keys.up} { move-window-up-or-to-workspace-up; }
Mod+Ctrl+${keys.right} { move-column-right; }
Mod+Shift+${keys.left} { focus-monitor-left; }
Mod+Shift+${keys.down} { focus-monitor-down; }
Mod+Shift+${keys.up} { focus-monitor-up; }
Mod+Shift+${keys.right} { focus-monitor-right; }
Mod+Shift+Ctrl+${keys.left} { move-column-to-monitor-left; }
Mod+Shift+Ctrl+${keys.down} { move-column-to-monitor-down; }
Mod+Shift+Ctrl+${keys.up} { move-column-to-monitor-up; }
Mod+Shift+Ctrl+${keys.right} { move-column-to-monitor-right; }
'';
genWorkspacesNavigation = keys: ''
Mod+${keys.first} { focus-workspace 1; }
Mod+${keys.second} { focus-workspace 2; }
Mod+${keys.third} { focus-workspace 3; }
Mod+${keys.fourth} { focus-workspace 4; }
Mod+${keys.fifth} { focus-workspace 5; }
Mod+${keys.sixth} { focus-workspace 6; }
Mod+${keys.seventh} { focus-workspace 7; }
Mod+${keys.eighth} { focus-workspace 8; }
Mod+${keys.ninth} { focus-workspace 9; }
Mod+Ctrl+Shift+${keys.first} { move-column-to-workspace 1; }
Mod+Ctrl+Shift+${keys.second} { move-column-to-workspace 2; }
Mod+Ctrl+Shift+${keys.third} { move-column-to-workspace 3; }
Mod+Ctrl+Shift+${keys.fourth} { move-column-to-workspace 4; }
Mod+Ctrl+Shift+${keys.fifth} { move-column-to-workspace 5; }
Mod+Ctrl+Shift+${keys.sixth} { move-column-to-workspace 6; }
Mod+Ctrl+Shift+${keys.seventh} { move-column-to-workspace 7; }
Mod+Ctrl+Shift+${keys.eighth} { move-column-to-workspace 8; }
Mod+Ctrl+Shift+${keys.ninth} { move-column-to-workspace 9; }
'';
in '' in ''
environment { environment {
DISPLAY ":123" DISPLAY ":123"
@ -429,8 +497,6 @@ in {
} }
window-rule { window-rule {
match title="TelegramDesktop"
match app-id="org.telegram.desktop"
match title="Картинка в картинці" match title="Картинка в картинці"
match title="Picture-in-Picture" match title="Picture-in-Picture"
open-floating true open-floating true
@ -460,36 +526,6 @@ in {
// block-out-from "screen-capture" // block-out-from "screen-capture"
block-out-from "screencast" block-out-from "screencast"
} }
// workspace "general"
// workspace "browse"
// workspace "chat"
// workspace "code"
// workspace "uni"
// workspace "games"
// workspace "sysadmin"
// workspace "media"
// workspace "bg"
// window-rule {
// match app-id=r#"^org\.telegram\.desktop$"#
// match app-id=r#"^im\.riot\.Riot$"#
// match app-id=r#"^WebCord$"#
// match app-id=r#"^signal$"#
// open-on-workspace "chat"
// }
// window-rule {
// match app-id=r#"^com\.heroicgameslauncher\.hgl$"#
// match app-id=r#"^net\.lutris\.Lutris$"#
// match app-id="steam"
// // match app-id=r#"^$"#
// open-on-workspace "games"
// }
// window-rule {
// match app-id=r#"^com\.obsproject\.Studio$"#
// open-on-workspace "bg"
// }
binds { binds {
Mod+Shift+Slash { show-hotkey-overlay; } Mod+Shift+Slash { show-hotkey-overlay; }
@ -532,7 +568,7 @@ in {
Ctrl+Print { screenshot-screen; } Ctrl+Print { screenshot-screen; }
Shift+Print { screenshot-window; } Shift+Print { screenshot-window; }
Caps_Lock { spawn "swayosd-client" "--caps-lock"; } // Caps_Lock { spawn "swayosd-client" "--caps-lock"; }
// XF86AudioRaiseVolume allow-when-locked=true { spawn "wpctl" "set-volume" "-l" "1.0" "@DEFAULT_AUDIO_SINK@" "5%+"; } // XF86AudioRaiseVolume allow-when-locked=true { spawn "wpctl" "set-volume" "-l" "1.0" "@DEFAULT_AUDIO_SINK@" "5%+"; }
// XF86AudioLowerVolume allow-when-locked=true { spawn "wpctl" "set-volume" "-l" "1.0" "@DEFAULT_AUDIO_SINK@" "5%-"; } // XF86AudioLowerVolume allow-when-locked=true { spawn "wpctl" "set-volume" "-l" "1.0" "@DEFAULT_AUDIO_SINK@" "5%-"; }
// XF86AudioMute allow-when-locked=true { spawn "wpctl" "set-mute" "@DEFAULT_AUDIO_SINK@" "toggle"; } // XF86AudioMute allow-when-locked=true { spawn "wpctl" "set-mute" "@DEFAULT_AUDIO_SINK@" "toggle"; }
@ -553,47 +589,12 @@ in {
XF86KbdBrightnessUp allow-when-locked=true { spawn "brightnessctl" "s" "5%+" "-d" "${keyboard}::kbd_backlight"; } XF86KbdBrightnessUp allow-when-locked=true { spawn "brightnessctl" "s" "5%+" "-d" "${keyboard}::kbd_backlight"; }
XF86KbdBrightnessDown allow-when-locked=true { spawn "brightnessctl" "s" "5%-" "-d" "${keyboard}::kbd_backlight"; } XF86KbdBrightnessDown allow-when-locked=true { spawn "brightnessctl" "s" "5%-" "-d" "${keyboard}::kbd_backlight"; }
Mod+Left { focus-column-left; }
Mod+Down { focus-window-or-workspace-down; }
Mod+Up { focus-window-or-workspace-up; }
Mod+Right { focus-column-right; }
Mod+${left} { focus-column-left; }
Mod+${down} { focus-window-or-workspace-down; }
Mod+${up} { focus-window-or-workspace-up; }
Mod+${right} { focus-column-right; }
Mod+Ctrl+Left { move-column-left; }
Mod+Ctrl+Down { move-window-down-or-to-workspace-down; }
Mod+Ctrl+Up { move-window-up-or-to-workspace-up; }
Mod+Ctrl+Right { move-column-right; }
Mod+Ctrl+${left} { move-column-left; }
Mod+Ctrl+${down} { move-window-down-or-to-workspace-down; }
Mod+Ctrl+${up} { move-window-up-or-to-workspace-up; }
Mod+Ctrl+${right} { move-column-right; }
Mod+Home { focus-column-first; } Mod+Home { focus-column-first; }
Mod+End { focus-column-last; } Mod+End { focus-column-last; }
Mod+Ctrl+Home { move-column-to-first; } Mod+Ctrl+Home { move-column-to-first; }
Mod+Ctrl+End { move-column-to-last; } Mod+Ctrl+End { move-column-to-last; }
Mod+Shift+Left { focus-monitor-left; }
Mod+Shift+Down { focus-monitor-down; }
Mod+Shift+Up { focus-monitor-up; }
Mod+Shift+Right { focus-monitor-right; }
Mod+Shift+${left} { focus-monitor-left; }
Mod+Shift+${down} { focus-monitor-down; }
Mod+Shift+${up} { focus-monitor-up; }
Mod+Shift+${right} { focus-monitor-right; }
Mod+Shift+Ctrl+Left { move-column-to-monitor-left; }
Mod+Shift+Ctrl+Down { move-column-to-monitor-down; }
Mod+Shift+Ctrl+Up { move-column-to-monitor-up; }
Mod+Shift+Ctrl+Right { move-column-to-monitor-right; }
Mod+Shift+Ctrl+${left} { move-column-to-monitor-left; }
Mod+Shift+Ctrl+${down} { move-column-to-monitor-down; }
Mod+Shift+Ctrl+${up} { move-column-to-monitor-up; }
Mod+Shift+Ctrl+${right} { move-column-to-monitor-right; }
Mod+Next { focus-workspace-down; } Mod+Next { focus-workspace-down; }
Mod+Prior { focus-workspace-up; } Mod+Prior { focus-workspace-up; }
Mod+Ctrl+Next { move-column-to-workspace-down; } Mod+Ctrl+Next { move-column-to-workspace-down; }
@ -618,62 +619,10 @@ in {
Mod+TouchpadScrollDown { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.02+"; } Mod+TouchpadScrollDown { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.02+"; }
Mod+TouchpadScrollUp { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.02-"; } Mod+TouchpadScrollUp { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.02-"; }
// Mod+1 { focus-workspace "general"; } ${genArrowNavigation arrows}
// Mod+2 { focus-workspace "browse"; } ${genArrowNavigation homerow-arrows}
// Mod+3 { focus-workspace "chat"; } ${genWorkspacesNavigation letters}
// Mod+4 { focus-workspace "code"; } ${genWorkspacesNavigation numbers}
// Mod+5 { focus-workspace "uni"; }
// Mod+6 { focus-workspace "games"; }
// Mod+7 { focus-workspace "sysadmin"; }
// Mod+8 { focus-workspace "media"; }
// Mod+9 { focus-workspace "bg"; }
// Mod+Ctrl+1 { move-column-to-workspace "general"; }
// Mod+Ctrl+2 { move-column-to-workspace "browse"; }
// Mod+Ctrl+3 { move-column-to-workspace "chat"; }
// Mod+Ctrl+4 { move-column-to-workspace "code"; }
// Mod+Ctrl+5 { move-column-to-workspace "uni"; }
// Mod+Ctrl+6 { move-column-to-workspace "games"; }
// Mod+Ctrl+7 { move-column-to-workspace "sysadmin"; }
// Mod+Ctrl+8 { move-column-to-workspace "media"; }
// Mod+Ctrl+9 { move-column-to-workspace "bg"; }
Mod+Q { focus-workspace 1; }
Mod+W { focus-workspace 2; }
Mod+F { focus-workspace 3; }
Mod+P { focus-workspace 4; }
Mod+B { focus-workspace 5; }
Mod+J { focus-workspace 6; }
Mod+L { focus-workspace 7; }
Mod+U { focus-workspace 8; }
Mod+Y { focus-workspace 9; }
Mod+Ctrl+Shift+Q { move-column-to-workspace 1; }
Mod+Ctrl+Shift+W { move-column-to-workspace 2; }
Mod+Ctrl+Shift+F { move-column-to-workspace 3; }
Mod+Ctrl+Shift+P { move-column-to-workspace 4; }
Mod+Ctrl+Shift+B { move-column-to-workspace 5; }
Mod+Ctrl+Shift+J { move-column-to-workspace 6; }
Mod+Ctrl+Shift+L { move-column-to-workspace 7; }
Mod+Ctrl+Shift+U { move-column-to-workspace 8; }
Mod+Ctrl+Shift+Y { move-column-to-workspace 9; }
Mod+1 { focus-workspace 1; }
Mod+2 { focus-workspace 2; }
Mod+3 { focus-workspace 3; }
Mod+4 { focus-workspace 4; }
Mod+5 { focus-workspace 5; }
Mod+6 { focus-workspace 6; }
Mod+7 { focus-workspace 7; }
Mod+8 { focus-workspace 8; }
Mod+9 { focus-workspace 9; }
Mod+Ctrl+Shift+1 { move-column-to-workspace 1; }
Mod+Ctrl+Shift+2 { move-column-to-workspace 2; }
Mod+Ctrl+Shift+3 { move-column-to-workspace 3; }
Mod+Ctrl+Shift+4 { move-column-to-workspace 4; }
Mod+Ctrl+Shift+5 { move-column-to-workspace 5; }
Mod+Ctrl+Shift+6 { move-column-to-workspace 6; }
Mod+Ctrl+Shift+7 { move-column-to-workspace 7; }
Mod+Ctrl+Shift+8 { move-column-to-workspace 8; }
Mod+Ctrl+Shift+9 { move-column-to-workspace 9; }
} }
''; '';
}; };