// Example config for Niri.
//
// See `man 5 niri` for the complete list of options.

output "eDP-1"{
    scale 1.0
    variable-refresh-rate
    transform "normal"
}

input {
    keyboard {
        xkb {
            layout "us"
        }
        repeat-delay 175
        repeat-rate 50
    }
    
    touchpad {
        tap
        dwt
        dwtp
        natural-scroll
        accel-speed 0.2
        accel-profile "adaptive"
    }
    
    mouse {
        accel-speed 0.2
        accel-profile "adaptive"
    }
    
    trackpoint {
        accel-speed 0.2
        accel-profile "adaptive"
    }
    
    tablet {
        map-to-output "eDP-1"
    }
    
    touch {
        map-to-output "eDP-1"
    }
    
    disable-power-key-handling
}

output "eDP-1" {
    scale 1.0
    transform "normal"
    position x=0 y=0
}

layout {
    gaps 16
    
    center-focused-column "never"

    always-center-single-column
    default-column-display "tabbed"

    tab-indicator {
        hide-when-single-tab
    }

    preset-column-widths {
        proportion 0.33333
        proportion 0.5
        proportion 0.66667
    }
    
    default-column-width {
        proportion 0.5;
    }
    
    focus-ring {
        width 4
        active-color "#8aadf4"
        inactive-color "#494d64"
    }
    
    border {
        width 2
        active-color "#8aadf4"
        inactive-color "#494d64"
    }

    shadow {
        softness 30
        spread 5
        offset x=0 y=5
        draw-behind-window true
        color "#00000070"
    }
    
    struts {
        left 64
        right 64
        top 64
        bottom 64
    }
}

prefer-no-csd

screenshot-path "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png"

hotkey-overlay {
    skip-at-startup
}

environment {
    QT_QPA_PLATFORM "wayland"
    DISPLAY ":0"
}

window-rule {
    match app-id="com.mitchellh.ghostty"
    default-column-width { proportion 0.5; }
}

window-rule {
    match app-id="firefox"
    default-column-width { proportion 0.75; }
}

window-rule {
    match at-startup=true app-id="org.keepassxc.KeePassXC"
    open-on-workspace "9"
}

spawn-at-startup "waybar"
spawn-at-startup "swaybg" "-i" "/home/nate/.config/niri/bg.png"
spawn-at-startup "nm-applet" "--indicator"
spawn-at-startup "swaync"
spawn-at-startup "keepassxc"
spawn-at-startup "sh" "-c" "sleep 5 && syncthingtray --wait"
spawn-at-startup "flatpak" "run" "org.signal.Signal"

binds {
    Mod+Shift+Slash { show-hotkey-overlay; }
    
    // Terminal - consistent with sway/hyprland
    Mod+Return { spawn "ghostty"; }
    
    // Application launcher - consistent with sway/hyprland  
    Mod+D { spawn "wofi" "--show" "drun"; }
    
    // File manager - consistent with sway/hyprland
    Mod+T { spawn "nautilus"; }
    
    // Browser - consistent with sway/hyprland
    Mod+W { spawn "firefox"; }
    
    // Close window - consistent with sway/hyprland
    Mod+Q { close-window; }
    
    // Arrow keys for focus movement
    Mod+Left  { focus-column-left; }
    Mod+Down  { focus-window-down; }
    Mod+Up    { focus-window-up; }
    Mod+Right { focus-column-right; }
    
    // Colemak-DH keys - consistent with sway/hyprland (n=left, i=down, e=up, o=right)
    Mod+N     { focus-column-left; }
    Mod+I     { focus-window-down; }
    Mod+E     { focus-window-up; }
    Mod+O     { focus-column-right; }
    
    // Arrow keys for window movement - consistent with sway/hyprland
    Mod+Shift+Left  { move-column-left; }
    Mod+Shift+Down  { move-window-down; }
    Mod+Shift+Up    { move-window-up; }
    Mod+Shift+Right { move-column-right; }
    
    // Colemak-DH keys for window movement - consistent with sway/hyprland
    Mod+Shift+N     { move-column-left; }
    Mod+Shift+I     { move-window-down; }
    Mod+Shift+E     { move-window-up; }
    Mod+Shift+O     { move-column-right; }
    
    Mod+Home { focus-column-first; }
    Mod+End  { focus-column-last; }
    Mod+Ctrl+Home { move-column-to-first; }
    Mod+Ctrl+End  { move-column-to-last; }
    
    // Monitor focus (keeping existing Shift pattern since this conflicts with window movement)
    Mod+Ctrl+Left  { focus-monitor-left; }
    Mod+Ctrl+Down  { focus-monitor-down; }
    Mod+Ctrl+Up    { focus-monitor-up; }
    Mod+Ctrl+Right { focus-monitor-right; }
    
    // Colemak-DH keys for monitor focus
    Mod+Ctrl+N     { focus-monitor-left; }
    Mod+Ctrl+I     { focus-monitor-down; }
    Mod+Ctrl+E     { focus-monitor-up; }
    Mod+Ctrl+O     { focus-monitor-right; }
    
    // Move column to monitor
    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; }
    
    // Colemak-DH keys for moving column to monitor
    Mod+Shift+Ctrl+N     { move-column-to-monitor-left; }
    Mod+Shift+Ctrl+I     { move-column-to-monitor-down; }
    Mod+Shift+Ctrl+E     { move-column-to-monitor-up; }
    Mod+Shift+Ctrl+O     { move-column-to-monitor-right; }
    
    // Workspace navigation (using Page keys to avoid conflicts with Colemak-DH movement)
    Mod+Page_Down      { focus-workspace-down; }
    Mod+Page_Up        { focus-workspace-up; }
    Mod+Ctrl+Page_Down { move-column-to-workspace-down; }
    Mod+Ctrl+Page_Up   { move-column-to-workspace-up; }
    
    Mod+Shift+Page_Down { move-workspace-down; }
    Mod+Shift+Page_Up   { move-workspace-up; }
    
    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+Minus { focus-workspace "scratch"; }
    Mod+Shift+1 { move-column-to-workspace 1; }
    Mod+Shift+2 { move-column-to-workspace 2; }
    Mod+Shift+3 { move-column-to-workspace 3; }
    Mod+Shift+4 { move-column-to-workspace 4; }
    Mod+Shift+5 { move-column-to-workspace 5; }
    Mod+Shift+6 { move-column-to-workspace 6; }
    Mod+Shift+7 { move-column-to-workspace 7; }
    Mod+Shift+8 { move-column-to-workspace 8; }
    Mod+Shift+9 { move-column-to-workspace 9; }
    
    Mod+Comma  { consume-window-into-column; }
    Mod+Period { expel-window-from-column; }
    
    Mod+R { switch-preset-column-width; }
    Mod+Shift+R { reset-window-height; }
    // Fullscreen - consistent with sway/hyprland
    Mod+F { fullscreen-window; }
    Mod+Shift+F { maximize-column; }
    
    // Floating toggle - consistent with sway/hyprland (niri doesn't have floating, using maximize instead)
    Mod+Space { maximize-column; }
    
    Mod+C { center-column; }
    
    Mod+bracketleft { set-column-width "-10%"; }
    Mod+bracketright { set-column-width "+10%"; }
    
    Mod+Shift+bracketleft { set-window-height "-10%"; }
    Mod+Shift+bracketright { set-window-height "+10%"; }
    
    // Screenshots - consistent with sway/hyprland  
    Mod+P { screenshot; }
    Mod+Shift+P { screenshot-screen; }
    
    // Traditional screenshot keys
    Print { screenshot; }
    Ctrl+Print { screenshot-screen; }
    Alt+Print { screenshot-window; }
    
    // Volume control
    XF86AudioRaiseVolume { spawn "pactl" "set-sink-volume" "@DEFAULT_SINK@" "+5%"; }
    XF86AudioLowerVolume { spawn "pactl" "set-sink-volume" "@DEFAULT_SINK@" "-5%"; }
    XF86AudioMute { spawn "pactl" "set-sink-mute" "@DEFAULT_SINK@" "toggle"; }
    XF86AudioMicMute { spawn "pactl" "set-source-mute" "@DEFAULT_SOURCE@" "toggle"; }
    
    // Media control
    XF86AudioPlay { spawn "playerctl" "play-pause"; }
    XF86AudioPause { spawn "playerctl" "pause"; }
    XF86AudioNext { spawn "playerctl" "next"; }
    XF86AudioPrev { spawn "playerctl" "previous"; }
    XF86AudioStop { spawn "playerctl" "stop"; }
    
    // Brightness control
    XF86MonBrightnessUp { spawn "brightnessctl" "set" "+5%"; }
    XF86MonBrightnessDown { spawn "brightnessctl" "set" "5%-"; }
    
    Mod+Shift+Q { quit; }
    Mod+Shift+Ctrl+P { power-off-monitors; }
    
    Mod+Shift+Ctrl+T { toggle-debug-tint; }
}

switch-events {
    lid-close { spawn "systemctl" "suspend"; }
    lid-open { spawn "notify-send" "The laptop lid is open!"; }
}
