// https://github.com/YaLTeR/niri/wiki/Configuration:-Overview

input {
    keyboard {
        xkb {
            layout "us,ru"
            options "grp:win_space_toggle,compose:ralt,caps:super"
        }
    }

    touchpad {
        tap
    }

    trackball {
        left-handed
    }
}

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

    preset-column-widths {
        proportion 0.33333
        proportion 0.5
        proportion 0.66667
    }

    default-column-width {}

    focus-ring {
        off
    }

    border {
        off
    }
}

spawn-at-startup "xwayland-satellite"
spawn-at-startup "xrandr --output eDP-1 --primary"
spawn-at-startup "wpaperd" "-d"
spawn-at-startup "systemctl --user start xss-lock"

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

hotkey-overlay {
  skip-at-startup
}

screenshot-path "~/screenshots/screenshot-%Y-%m-%d_%H-%M-%S.png"

animations {
    slowdown 0.3
}

binds {
    Mod+Shift+Slash { show-hotkey-overlay; }

    Mod+T { spawn "emacsclient" "--no-wait" "--create-frame" "--eval" "(vterm)"; }
    Mod+Shift+T { spawn "alacritty"; } // fallback terminal
    Mod+D { spawn "xfce4-appfinder" "--disable-server"; }
    Super+Alt+L { spawn "swaylock" "-fFkl" "-c" "#008080"; }
    Super+B { spawn "emacsclient" "-e" "(niri-go-anywhere-external)"; }

    // Volume control
    XF86AudioRaiseVolume allow-when-locked=true { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.1+"; }
    XF86AudioLowerVolume allow-when-locked=true { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.1-"; }
    XF86AudioMute        allow-when-locked=true { spawn "wpctl" "set-mute" "@DEFAULT_AUDIO_SINK@" "toggle"; }
    XF86AudioMicMute     allow-when-locked=true { spawn "wpctl" "set-mute" "@DEFAULT_AUDIO_SOURCE@" "toggle"; }

    // Brightness control
    XF86MonBrightnessUp allow-when-locked=true { spawn "light" "-A" "5"; }
    Shift+XF86MonBrightnessUp allow-when-locked=true { spawn "light" "-A" "1"; }
    XF86MonBrightnessDown allow-when-locked=true { spawn "light" "-U" "5"; }
    Shift+XF86MonBrightnessDown allow-when-locked=true { spawn "light" "-U" "1"; }

    Mod+Q { close-window; }

    Mod+Left      { focus-column-or-monitor-left; }
    Mod+Right     { focus-column-or-monitor-right; }
    Mod+Down      { focus-column-or-monitor-right; }
    Mod+Up        { focus-column-or-monitor-left; }
    Mod+J         { focus-column-or-monitor-left; }
    Mod+K         { focus-column-or-monitor-right; }
    Mod+L         { focus-window-up; }
    Mod+Semicolon { focus-window-down; }

    Mod+Ctrl+Left  { move-column-left-or-to-monitor-left; }
    Mod+Ctrl+Right { move-column-right-or-to-monitor-right; }
    Mod+Ctrl+J     { move-column-left-or-to-monitor-left; }
    Mod+Ctrl+K     { move-column-right-or-to-monitor-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; }

    // Scroll (or move windows) between columns when holding the modifier down.
    Mod+WheelScrollDown      cooldown-ms=150 { focus-column-or-monitor-right; }
    Mod+WheelScrollUp        cooldown-ms=150 { focus-column-or-monitor-left; }
    Mod+Ctrl+WheelScrollDown cooldown-ms=150 { move-column-right-or-to-monitor-right; }
    Mod+Ctrl+WheelScrollUp   cooldown-ms=150 { move-column-left-or-to-monitor-left; }

    Mod+Comma  { consume-window-into-column; }
    Mod+Period { expel-window-from-column; }

    // There are also commands that consume or expel a single window to the side.
    // Mod+BracketLeft  { consume-or-expel-window-left; }
    // Mod+BracketRight { consume-or-expel-window-right; }

    Mod+R { switch-preset-column-width; }
    Mod+Shift+R { reset-window-height; }
    Mod+F { maximize-column; }
    Mod+Shift+F { fullscreen-window; }
    Mod+C { center-column; }

    Mod+Minus { set-column-width "-10%"; }
    Mod+Equal { set-column-width "+10%"; }

    // Finer height adjustments when in column with other windows.
    Mod+Shift+Minus { set-window-height "-2%"; }
    Mod+Shift+Equal { set-window-height "+2%"; }

    Print { screenshot; }
    Ctrl+Print { screenshot-screen; }
    Alt+Print { screenshot-window; }

    Mod+Shift+E { quit; }
}

// tverskoy screen fix
output "AU Optronics 0x5A2D Unknown" {
    scale 1.0
}
