input {
    keyboard {
      repeat-delay 250
      repeat-rate 50
    }

    touchpad {
      tap
    }

    trackpoint {
        accel-speed 1.0
    }
}

gestures {
    hot-corners {
        off
    }
}

overview {
    backdrop-color "#151515"
}

layout {
    gaps 12

    center-focused-column "never"

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

    default-column-width { proportion 0.5; }
    focus-ring {
        width 2
        active-color "#8c977d"
        inactive-color "#424242"
    }

    shadow {
        on
        softness 30
        spread 5
        offset x=0 y=5
        color "#151515"
    }
}

environment {
  QT_QPA_PLATFORM "wayland"
  QT_QPA_PLATFORM_THEME "qt5ct:qt6ct"
  DISPLAY ":0"
  GTK_CSD "0"
  ELECTRON_OZONE_PLATFORM_HINT "auto"
}

// Spawn services
spawn-at-startup "xwayland-satellite"
spawn-at-startup "swaybg" "-i" "/home/fern/.config/niri/bg.jpg"
spawn-at-startup "waybar"
spawn-at-startup "pipewire"
spawn-at-startup "nextcloud" "--background"
spawn-at-startup "gnome-keyring-daemon" "-d"
spawn-at-startup "udiskie" "-a" "-n" "-t" "-F" "--no-terminal"
spawn-at-startup "wlsunset" "-l" "-27.6" "-L" "121.6"
spawn-at-startup "swayidle" "-w" "timeout 300 gtklock -d" "before-sleep gtklock -d"
spawn-at-startup "/usr/libexec/polkit-gnome-authentication-agent-1"

// Spawn apps
spawn-at-startup "firefox"
spawn-at-startup "element-desktop"
spawn-at-startup "flatpak" "run" "org.jeffvli.feishin"
spawn-at-startup "flatpak" "run" "org.signal.Signal"

hotkey-overlay {
	skip-at-startup
}

prefer-no-csd

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

window-rule {
  match app-id="Firefox" at-startup=true
  open-maximized true
  open-on-workspace "browser"
}

window-rule {
  match app-id="^libreoffice"
  match app-id="^gimp-3.0"
  open-maximized true
  open-on-workspace "work"
}

window-rule {
  match app-id="PrismLauncher$"
  open-on-workspace "games"
}

window-rule {
  match title="^Minecraft"
  open-on-workspace "games"
  open-fullscreen true
}

window-rule {
  match app-id="feishin"
  open-on-workspace "media"
  open-maximized true
}

window-rule {
  match app-id="Signal"
  match app-id="Element"
  open-on-workspace "chat"
  open-maximized true
}

binds {
    Mod+Return { spawn "kitty"; }
    Mod+Space { spawn "fuzzel"; }
    Mod+E { spawn "bemoji" "-t" "-c" "-n"; }

    XF86AudioMute        allow-when-locked=true { spawn "wpctl" "set-mute" "@DEFAULT_AUDIO_SINK@" "toggle"; }
    XF86AudioLowerVolume allow-when-locked=true { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "1%-"; }
    XF86AudioRaiseVolume allow-when-locked=true { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "1%+"; }
    XF86AudioMicMute     allow-when-locked=true { spawn "wpctl" "set-mute" "@DEFAULT_AUDIO_SOURCE@" "toggle"; }
    XF86MonBrightnessDown allow-when-locked=true { spawn "brillo" "-U" "5"; }
    XF86MonBrightnessUp allow-when-locked=true { spawn "brillo" "-A" "5"; }
    XF86Display { spawn "wdisplays"; }
    XF86Tools allow-when-locked=true { spawn "brillo" "-S" "100"; }
    XF86AudioPlay allow-when-locked=true { spawn "playerctl" "play-pause"; }
    XF86AudioRewind allow-when-locked=true { spawn "playerctl" "previous"; }
    XF86AudioForward allow-when-locked=true { spawn "playerctl" "next"; }

    Mod+Q { close-window; }

    Mod+H     { focus-column-left; }
    Mod+L     { focus-column-right; }
    Mod+J     { focus-window-down; }
    Mod+K     { focus-window-up; }

    Mod+Shift+H     { move-column-left; }
    Mod+Shift+L     { move-column-right; }
    Mod+Shift+J     { move-window-down; }
    Mod+Shift+K     { move-window-up; }

    Mod+BracketLeft  { consume-or-expel-window-left; }
    Mod+BracketRight { consume-or-expel-window-right; }

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

    Mod+R { switch-preset-column-width; }
    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%"; }
    Mod+Shift+Minus { set-window-height "-10%"; }
    Mod+Shift+Equal { set-window-height "+10%"; }

    Mod+V       { toggle-window-floating; }
    Mod+Shift+V { switch-focus-between-floating-and-tiling; }
    Mod+W { toggle-column-tabbed-display; }

    Mod+U              { focus-workspace-down; }
    Mod+I              { focus-workspace-up; }

    Mod+1 { focus-workspace "browser"; }
    Mod+2 { focus-workspace "work"; }
    Mod+3 { focus-workspace "games"; }
    Mod+4 { focus-workspace "media"; }
    Mod+5 { focus-workspace "chat"; }

    Mod+Shift+U     { move-column-to-workspace-down; }
    Mod+Shift+I     { move-column-to-workspace-up; }

    Mod+Tab     { focus-monitor-next; }
    Mod+Shift+Tab { move-column-to-monitor-next; }

    Mod+Up { toggle-overview; }

    Mod+P { screenshot-screen; }
    Mod+Shift+P { screenshot; }
    Mod+Ctrl+P { screenshot-window; }

    Mod+Shift+E  { spawn "/home/fern/.config/niri/power-menu"; }
}

workspace "browser" {
  open-on-output "Chimei Innolux Corporation 0x14F3 Unknown"
}

workspace "work" {
  open-on-output "Chimei Innolux Corporation 0x14F3 Unknown"
}

workspace "games" {
  open-on-output "Chimei Innolux Corporation 0x14F3 Unknown"
}

workspace "media" {
  open-on-output "Dell Inc. DELL P2018H FW7Y682903MU"
}

workspace "chat" {
  open-on-output "Dell Inc. DELL P2018H FW7Y682903MU"
}
