//
// MISCELLANEOUS
//


screenshot-path "~/Pictures/"// save screenshots just to clipboard
prefer-no-csd // (Client Side Decorations) ask clients to not add their own decorations

hotkey-overlay {
    skip-at-startup
}

debug {
    // Allows notification actions and window activation from Noctalia
    honor-xdg-activation-with-invalid-serial
}

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

//
// INPUTS
//
input {
    keyboard {
        xkb {
            layout "us"
        }
        repeat-delay 225
        repeat-rate 40
    }
    
    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
    warp-mouse-to-focus mode="center-xy"
    focus-follows-mouse
}

//
// LAYOUT
//
layout {
    gaps 2

    center-focused-column "on-overflow"
    always-center-single-column
    default-column-display "normal"

    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 0
    }

    border {
            active-gradient from="#8ac926" to="#6a994e" angle=45 in="oklch longer hue" relative-to="workspace-view"
            inactive-gradient from="#606c38" to="#344e41" angle=45 in="oklch longer hue" relative-to="workspace-view"
    }

    shadow {
        softness 30
        spread 5
        offset x=8 y=8
        draw-behind-window true
        color "#00444444"
    }

    struts {
        left 10
        right 10
        top 10
        bottom 10
    }
}


//
// WINDOW RULES
//

// All windows - corner radius, opacity
window-rule {
    geometry-corner-radius 20
    clip-to-geometry true
}

window-rule {
    match is-active=true
    opacity 1.00
}

window-rule {
    match is-floating=true
    opacity 0.92
}

// Net windows
window-rule {
    match app-id="firefox"

    default-column-width { proportion 1.0; }
    open-on-workspace "net"
}

// Chat windows
window-rule {
    match app-id=r#"^com\.discordapp\.Discord$"#
    match app-id=r#"^org\.signal\.Signal$"#

    default-column-width { proportion 0.8; }
    block-out-from "screencast"
}

// File browser
window-rule {
    match app-id="org.gnome.Nautilus"

    open-floating true
    open-focused true
    block-out-from "screencast"
}

// Steam windows
window-rule {
    match app-id="steam" title="Friends List"

    open-floating true
    open-focused false
}

// Bright border on screen-shared windows
window-rule {
    match is-window-cast-target=true

    focus-ring {
        active-color "#f38ba8"
        inactive-color "#7d0d2d"
    }

    border {
        inactive-color "#7d0d2d"
    }

    shadow {
        color "#7d0d2d70"
    }

    tab-indicator {
        active-color "#f38ba8"
        inactive-color "#7d0d2d"
    }
}

// Block out notifications from screencasts.
layer-rule {
    match namespace="^notifications$"

    block-out-from "screencast"
}

// Noctalia overview wallpaper on backdrop (blurred in overview mode)
layer-rule {
    match namespace="^noctalia-overview*"
    place-within-backdrop true
}

//
// BINDS (QWERTY Layout)
//

binds {
    Mod+Shift+Slash { show-hotkey-overlay; }
    
    // Terminal
    Mod+Return { spawn "ghostty"; }
    
    // Application launcher - Noctalia launcher
    Mod+D { spawn "noctalia-shell" "ipc" "call" "launcher" "toggle"; }
    
    // File manager
    Mod+T { spawn "nautilus"; }
    
    // Browser
    Mod+W { spawn "firefox"; }
    
    // Close window
    Mod+Q { close-window; }
    
    // QWERTY navigation (H=left, J=down, K=up, L=right)
    Mod+H     { focus-column-left; }
    Mod+J     { focus-window-down; }
    Mod+K     { focus-window-up; }
    Mod+L     { focus-column-right; }
    
    // 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; }
    
    // QWERTY window movement
    Mod+Shift+H     { move-column-left; }
    Mod+Shift+J     { move-window-down; }
    Mod+Shift+K     { move-window-up; }
    Mod+Shift+L     { move-column-right; }
    
    // Arrow keys for window movement
    Mod+Shift+Left  { move-column-left; }
    Mod+Shift+Down  { move-window-down; }
    Mod+Shift+Up    { move-window-up; }
    Mod+Shift+Right { 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 - QWERTY
    Mod+Ctrl+H     { focus-monitor-left; }
    Mod+Ctrl+J     { focus-monitor-down; }
    Mod+Ctrl+K     { focus-monitor-up; }
    Mod+Ctrl+L     { focus-monitor-right; }
    
    // Monitor focus - Arrow keys
    Mod+Ctrl+Left  { focus-monitor-left; }
    Mod+Ctrl+Down  { focus-monitor-down; }
    Mod+Ctrl+Up    { focus-monitor-up; }
    Mod+Ctrl+Right { focus-monitor-right; }
    
    // Move column to monitor - QWERTY
    Mod+Shift+Ctrl+H     { move-column-to-monitor-left; }
    Mod+Shift+Ctrl+J     { move-column-to-monitor-down; }
    Mod+Shift+Ctrl+K     { move-column-to-monitor-up; }
    Mod+Shift+Ctrl+L     { move-column-to-monitor-right; }
    
    // Move column to monitor - Arrow keys
    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; }
    
    // Workspace navigation
    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+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
    Mod+F { maximize-column; }
    Mod+Shift+F { fullscreen-window; }

    // Floating toggle
    Mod+Space { toggle-window-floating; }
    Mod+Shift+Space { switch-focus-between-floating-and-tiling; }

    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%"; }

    //
    // Utilities
    //

    // Notifications - Noctalia notification panel
    Mod+Shift+C { spawn "noctalia-shell" "ipc" "call" "notificationHistory" "toggle"; }

    // Screenshots
    Mod+P { screenshot; }
    Mod+Shift+P { screenshot-screen; }
    
    // Traditional screenshot keys
    Print { screenshot; }
    Ctrl+Print { screenshot-screen; }
    Alt+Print { screenshot-window; }
    
    // Volume control (via Noctalia)
    XF86AudioRaiseVolume allow-when-locked=true { spawn "noctalia-shell" "ipc" "call" "volume" "increase"; }
    XF86AudioLowerVolume allow-when-locked=true { spawn "noctalia-shell" "ipc" "call" "volume" "decrease"; }
    XF86AudioMute allow-when-locked=true { spawn "noctalia-shell" "ipc" "call" "volume" "muteOutput"; }
    XF86AudioMicMute allow-when-locked=true { spawn "noctalia-shell" "ipc" "call" "volume" "muteInput"; }
    
    // 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 (via Noctalia)
    XF86MonBrightnessUp { spawn "noctalia-shell" "ipc" "call" "brightness" "increase"; }
    XF86MonBrightnessDown { spawn "noctalia-shell" "ipc" "call" "brightness" "decrease"; }

    // Screen rotation
    Mod+Alt+Up    { spawn "niri" "msg" "output" "eDP-1" "transform" "normal"; }
    Mod+Alt+Right { spawn "niri" "msg" "output" "eDP-1" "transform" "90"; }
    Mod+Alt+Down  { spawn "niri" "msg" "output" "eDP-1" "transform" "180"; }
    Mod+Alt+Left  { spawn "niri" "msg" "output" "eDP-1" "transform" "270"; }
    
    // Session/Power menu (via Noctalia)
    Mod+Shift+Q { spawn "noctalia-shell" "ipc" "call" "sessionMenu" "toggle"; }
    Mod+Ctrl+Q { quit; }
    Mod+Shift+Ctrl+P { power-off-monitors; }

    // Dictation
    Mod+grave { spawn "hyprvoice" "toggle"; }

}

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